• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/

Lines Matching +defs:existing +defs:buffer

38 ;; The buffer at the start of the list will be the one visited when
40 ;; narrowed down so that gradually the buffer you want will be at the
42 ;; buffer names in the list until the one you want is at the top of
47 ;; <cook@sightpath.com> wrote a similar buffer switching package, but
48 ;; does exact matching rather than substring matching on buffer names.
74 ;; If I want the first buffer in the list, I simply press RET. If I
81 ;; Since there is only one matching buffer left, it is given in [] and we
83 ;; to that buffer.
88 ;; prompted to create a new buffer called "234a".
91 ;; can specify the buffer using only a few keystrokes. In the above
92 ;; example, the quickest way to get to the "123456" buffer would be
93 ;; just to type 4 and then RET (assuming there isn't any newer buffer
96 ;; To see a full list of all matching buffers in a separate buffer,
99 ;; separate buffer.
101 ;; The buffer at the head of the list can be killed by pressing C-k.
102 ;; If the buffer needs saving, you will be queried before the buffer
105 ;; If you find that the file you are after is not in a buffer, you can
168 ;; font-lock is used to highlight the first matching buffer. To
170 ;; the matching buffer name was suggested by Carsten Dominik
173 ;; Replacement for read-buffer
175 ;; iswitchb-read-buffer has been written to be a drop in replacement
176 ;; for the normal buffer selection routine `read-buffer'. To use
177 ;; iswitch for all buffer selections in Emacs, add:
178 ;; (setq read-buffer-function 'iswitchb-read-buffer)
181 ;; (defalias 'read-buffer 'iswitchb-read-buffer)
182 ;; since `read-buffer' is defined in lisp.
196 ;; (iswitchb-read-buffer prompt)))
222 ;; If you switch to a buffer that is visible in another frame,
234 ;; example and see all buffer names ending in `c'. No completion
242 ;; first version of this package, iswitch-buffer. Thanks also to many
281 "*Non-nil if searching of buffer names should ignore case.
287 (defcustom iswitchb-buffer-ignore
289 "*List of regexps or functions matching buffer names to ignore.
295 (put 'iswitchb-buffer-ignore 'risky-local-variable t)
324 `iswitchb-prev-match', which cycle the buffer list."
328 ;;; Examples for setting the value of iswitchb-buffer-ignore
332 ; (set-buffer name)
335 ;(setq iswitchb-buffer-ignore '("^ " iswitchb-ignore-c-mode))
336 ;(setq iswitchb-buffer-ignore '("^ " "\\.c$" "\\.h$"))
339 "*How to switch to new buffer when using `iswitchb-buffer'.
341 `samewindow' Show new buffer in same window
342 `otherwindow' Show new buffer in another window (same frame)
343 `display' Display buffer in another window without switching to it
344 `otherframe' Show new buffer in another frame
345 `maybe-frame' If a buffer is visible in another frame, prompt to ask if you
346 you want to see the buffer in the same window of the current
348 `always-frame' If a buffer is visible in another frame, raise that
349 frame. Otherwise, visit the buffer in the same window."
365 "*Non-nil means create new buffer if no buffer matches substring.
371 "*Non-nil means prompt user to confirm before creating new buffer.
382 (defcustom iswitchb-use-frame-buffer-list nil
383 "*Non-nil means use the currently selected frame's buffer list."
411 "Iswitchb face for single matching buffer name."
418 "Iswitchb face for current matching buffer name."
425 "Iswitchb face for matching virtual buffer names.
442 "Stores the method for viewing the selected buffer.
450 (make-variable-buffer-local 'iswitchb-eoinput)
461 "Non-nil means use `iswitchb-buffer' completion feedback.
487 (define-key map "\C-j" 'iswitchb-select-buffer-text)
491 (define-key map "\C-k" 'iswitchb-kill-buffer)
494 "Minibuffer keymap for `iswitchb-buffer'.")
498 (dolist (b '((switch-to-buffer . iswitchb-buffer)
499 (switch-to-buffer-other-window . iswitchb-buffer-other-window)
500 (switch-to-buffer-other-frame . iswitchb-buffer-other-frame)
501 (display-buffer . iswitchb-display-buffer)))
509 "History of buffers selected using `iswitchb-buffer'.")
512 "Flag to monitor how `iswitchb-buffer' exits.
513 If equal to `takeprompt', we use the prompt as the buffer name to be
516 (defvar iswitchb-buffer-ignore-orig nil
517 "Stores original value of `iswitchb-buffer-ignore'.")
520 "Default buffer for iswitchb.")
524 "Non-nil if matching buffer must be selected.")
527 "Stores a temporary version of the buffer list being created.")
544 "Set up the keymap for `iswitchb-buffer'.
557 (define-key map "\C-j" 'iswitchb-select-buffer-text)
562 (define-key map "\C-k" 'iswitchb-kill-buffer)
569 "Switch to buffer matching a substring.
571 displayed. When you have found the buffer you want, it can then be
576 RET Select the buffer at the front of the list of matches. If the
577 list is empty, possibly prompt to create new buffer.
579 \\[iswitchb-select-buffer-text] Select the current prompt as the buffer.
580 If no buffer is found, prompt for a new one.
585 matches all buffers. If there is only one match, select that buffer.
589 \\[iswitchb-toggle-case] Toggle case-sensitive searching of buffer names.
592 \\[iswitchb-kill-buffer] Kill buffer at head of buffer list."
594 ;;`iswitchb-buffer-ignore')
598 (buf (iswitchb-read-buffer prompt)))
601 ;; Choose the buffer name: either the text typed in, or the head
607 (message "Won't make invalid regexp named buffer"))
609 ;; View the buffer
613 (if (get-buffer buf)
614 ;; buffer exists, so view it and then exit
615 (iswitchb-visit-buffer buf)
616 ;; else buffer doesn't exist
617 (iswitchb-possible-new-buffer buf)))
620 (defun iswitchb-read-buffer (prompt &optional default require-match
622 "Replacement for the built-in `read-buffer'.
623 Return the name of a buffer selected.
625 DEFAULT if given is the default buffer to be selected, which will
627 If REQUIRE-MATCH is non-nil, an existing-buffer must be selected.
643 (buffer-name default)
656 ;; prompt the user for the buffer name
665 (get-buffer iswitchb-final-text))
666 ;; This happens for example if the buffer was chosen with the mouse.
670 ;; If no buffer matched, but a virtual buffer was selected, visit
671 ;; that file now and act as though that buffer had been selected.
673 (not (iswitchb-existing-buffer-p)))
681 (not (iswitchb-existing-buffer-p)))
682 (error "Must specify valid buffer"))
690 ;; Or possibly choose the default buffer
696 (defun iswitchb-existing-buffer-p ()
697 "Return non-nil if there is a matching buffer."
718 "Try and complete the current pattern amongst the buffer names."
762 "Toggle ignoring buffers specified with `iswitchb-buffer-ignore'."
764 (if iswitchb-buffer-ignore
766 (setq iswitchb-buffer-ignore-orig iswitchb-buffer-ignore)
767 (setq iswitchb-buffer-ignore nil))
769 (setq iswitchb-buffer-ignore iswitchb-buffer-ignore-orig))
778 (iswitchb-existing-buffer-p))
783 (defun iswitchb-select-buffer-text ()
784 "Select the buffer named by the prompt.
785 If no buffer exactly matching the prompt exists, maybe create a new one."
791 "Drop into `find-file' from buffer switching."
842 created to allow the user to further modify the order of the buffer names
843 in this list. If DEFAULT is non-nil, and corresponds to an existing buffer,
851 (let ((b-name (buffer-name x)))
857 (buffer-list (and iswitchb-use-frame-buffer-list
892 (let ((buf (buffer-name (window-buffer win))))
912 &optional string-format buffer-list)
921 (dolist (x buffer-list (nreverse ret))
922 (setq name (if (stringp x) x (buffer-name x)))
931 "Return t if the buffer BUFNAME should be ignored."
933 (re-list iswitchb-buffer-ignore)
1002 "Show possible completions in a *Completions* buffer."
1003 ;; we could allow this buffer to be used to select match, but I think
1008 (let ((buf (current-buffer))
1014 ;; scroll buffer
1016 (set-buffer temp-buf)
1017 (setq win (get-buffer-window temp-buf))
1021 (set-buffer buf))
1023 (with-output-to-temp-buffer temp-buf
1036 (with-current-buffer standard-output
1045 (defun iswitchb-kill-buffer ()
1046 "Kill the buffer at the head of `iswitchb-matches'."
1055 (kill-buffer buf)
1057 ;; Check if buffer exists. XEmacs gnuserv.el makes alias
1058 ;; for kill-buffer which does not return t if buffer is
1059 ;; killed, so we can't rely on kill-buffer return value.
1060 (if (get-buffer buf)
1061 ;; buffer couldn't be killed.
1063 ;; else buffer was killed so remove name from list.
1067 (defun iswitchb-visit-buffer (buffer)
1068 "Visit buffer named BUFFER according to `iswitchb-method'."
1072 (switch-to-buffer buffer))
1076 ((and (setq win (iswitchb-window-buffer-p buffer))
1087 ;; No buffer in other frames...
1088 (switch-to-buffer buffer)
1092 (switch-to-buffer-other-window buffer))
1095 (display-buffer buffer))
1099 (switch-to-buffer-other-frame buffer)
1104 (defun iswitchb-possible-new-buffer (buf)
1105 "Possibly create and visit a new buffer called BUF."
1115 "No buffer matching `%s', create one? "
1117 ;; then create a new buffer
1119 (setq newbufcreated (get-buffer-create buf))
1120 (if (fboundp 'set-buffer-major-mode)
1121 (set-buffer-major-mode newbufcreated))
1122 (iswitchb-visit-buffer newbufcreated))
1123 ;; else wont create new buffer
1124 (message "no buffer matching `%s'" buf))))
1126 (defun iswitchb-window-buffer-p (buffer)
1131 ;;If the buffer is visible in current frame, return nil
1132 (if (memq buffer blist)
1135 (get-buffer-window buffer 0) ; better than 'visible
1139 "Set up default keybindings for `iswitchb-buffer'.
1146 (global-set-key "\C-xb" 'iswitchb-buffer)
1147 (global-set-key "\C-x4b" 'iswitchb-buffer-other-window)
1148 (global-set-key "\C-x4\C-o" 'iswitchb-display-buffer)
1149 (global-set-key "\C-x5b" 'iswitchb-buffer-other-frame))
1151 (defun iswitchb-buffer ()
1152 "Switch to another buffer.
1154 The buffer name is selected interactively by typing a substring. The
1155 buffer is displayed according to `iswitchb-default-method' -- the
1163 (defun iswitchb-buffer-other-window ()
1164 "Switch to another buffer and show it in another window.
1165 The buffer name is selected interactively by typing a substring.
1171 (defun iswitchb-display-buffer ()
1172 "Display a buffer in another window but don't select it.
1173 The buffer name is selected interactively by typing a substring.
1179 (defun iswitchb-buffer-other-frame ()
1180 "Switch to another buffer and show it in another frame.
1181 The buffer name is selected interactively by typing a substring.
1187 ;;; XEmacs hack for showing default buffer
1190 ;; buffer to switch to, but XEmacs doesn't -- presumably there is a
1198 "Display default buffer when first entering minibuffer.
1229 1. It prints a default buffer name when there is no text yet entered.
1232 (let ((contents (buffer-substring (minibuffer-prompt-end) (point-max)))
1233 (buffer-undo-list t))
1304 (null (get-file-buffer (car head)))
1338 ;; matching buffer name in full
1392 "Set up minibuffer for `iswitchb-buffer'.
1401 "Run before command in `iswitchb-buffer'."
1405 "Run after command in `iswitchb-buffer'."
1418 (let ((buffer-undo-list buffer-undo-list )) ; prevent entry
1426 "Return non-nil if we are using `iswitchb-buffer'."
1432 `iswitchb-make-buflist-hook'. Any buffer matching the regexps