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

Lines Matching +defs:bury +defs:buffer

32 ;; buffer in a way similar to `list-buffers' and `electric-buffer-list':
33 ;; The new buffer offers a Buffer Selection Menu for manipulating
34 ;; the buffer list and buffers.
50 ;; for buffer selection or optional bind a key to main function `bs-show'
59 ;; bs-show will generate a new buffer named *buffer-selection*, which shows
63 ;; in *buffer-selection*. See docstring of variable `bs-configurations' for
67 ;; `list-buffers' and `electric-buffer-list'.
74 ;; - goes to top of buffer list if you are on last line and press down.
75 ;; - goes to end of buffer list if you are on first line and press up.
76 ;; - Offer an alternative buffer list by prefix key C-u.
80 ;; This package offers two functions for buffer cycling. If you want to cycle
81 ;; through buffer list you can use `bs-cycle-next' or `bs-cycle-previous'.
90 ;; the logical buffer list. If buffer list is sorted by size you
91 ;; won't be able to cycle to the smallest buffer.
111 ;; You can define functions for sorting the buffer list.
117 ;; by buffer name, by mode, by size, or by filename
119 ;; Configure buffer cycling
121 ;; When cycling through buffer list the functions for cycling will use
122 ;; the current configuration of bs to calculate the buffer list.
128 ;; configuration perhaps is "files" which ignores buffer *scratch*.
141 "Buffer Selection: Maintaining buffers by buffer menu."
148 "Buffer Selection appearance: Appearance of bs buffer menu."
163 "*List specifying the layout of a Buffer Selection Menu buffer.
177 The function gets as parameter the buffer where we have started
178 buffer selection and the list of all buffers to show. The function must
184 "Return a regexp matching the first line of a Buffer Selection Menu buffer."
217 A buffer whose name matches this regular expression will not be
218 included in the buffer list.")
222 A buffer whose name matches this regular expression will be
223 included in the buffer list.
230 A buffer whose name matches this regular expression will
237 The function gets one argument - the buffer to test. The function must
238 return a value different from nil to ignore the buffer in
243 The function gets one argument - the buffer to test.")
245 (defvar bs-buffer-sort-function nil
249 (defcustom bs-maximal-buffer-name-column 45
250 "*Maximum column width for buffer names.
251 The column for buffer names has dynamic width. The width depends on
253 width is bounded by `bs-maximal-buffer-name-column'.
254 See also `bs-minimal-buffer-name-column'."
258 (defcustom bs-minimal-buffer-name-column 15
259 "*Minimum column width for buffer names.
260 The column for buffer names has dynamic width. The width depends on
262 width is bounded by `bs-minimal-buffer-name-column'.
263 See also `bs-maximal-buffer-name-column'."
272 ("files" nil nil nil bs-visits-non-file bs-sort-buffer-interns-are-last)
274 bs-sort-buffer-interns-are-last)
275 ("all-intern-last" nil nil nil nil bs-sort-buffer-interns-are-last))
282 `bs-dont-show-regexp', `bs-dont-show-function' and `bs-buffer-sort-function'.
307 "*Name of configuration used when cycling through the buffer list.
315 "*String added in column 1 indicating a buffer will always be shown."
320 "*String added in column 1 indicating a buffer will never be shown."
325 "*String added in column 1 indicating the current buffer."
330 "*String added in column 1 indicating the current buffer when it is marked."
335 "*String added in column 1 indicating a marked buffer."
340 "*String added in column 1 indicating a unmarked buffer."
345 "Maximum length of all displayed buffer names.
352 (defvar bs-buffer-show-mark nil
353 "Flag for the current mode for showing this buffer.
354 A value of nil means buffer will be shown depending on the current
356 A value of `never' means to never show the buffer.
357 A value of `always' means to show buffer regardless of the configuration.")
359 (make-variable-buffer-local 'bs-buffer-show-mark)
367 "Compare buffers B1 and B2 by buffer name."
368 (string< (buffer-name b1)
369 (buffer-name b2)))
373 (string< (or (buffer-file-name b1) "")
374 (or (buffer-file-name b2) "")))
379 (string< (progn (set-buffer b1) (format "%s" mode-name))
380 (progn (set-buffer b2) (format "%s" mode-name)))))
383 "Compare buffers B1 and B2 by buffer size."
385 (< (progn (set-buffer b1) (buffer-size))
386 (progn (set-buffer b2) (buffer-size)))))
398 FUNCTION nil means don't sort the buffer list. Otherwise the functions
408 "Define a new function for buffer sorting in Buffer Selection Menu.
410 A value of nil for FUN means don't sort the buffer list. Otherwise the
425 "Description of the current function for sorting the buffer list.
439 (defvar bs--buffer-coming-from nil
440 "The buffer in which the user started the current Buffer Selection Menu.")
451 (defvar bs--intern-show-never "^ \\|\\*buffer-selection\\*"
453 A buffer whose name matches this regular expression will never be
454 included in the buffer list.")
489 (define-key map "b" 'bs-bury-buffer)
507 (define-key map "+" 'bs-set-current-buffer-to-show-always)
508 ;;(define-key map "-" 'bs-set-current-buffer-to-show-never)
522 (defun bs-buffer-list (&optional list sort-description)
527 and `bs-buffer-sort-function'.
531 list (or list (buffer-list)))
534 (let* ((buffername (buffer-name (car list)))
552 (show-flag (buffer-local-value 'bs-buffer-show-mark (car list))))
565 ;; The current buffer which was the start point of bs should be an element
567 ;; buffer we started bs-show.
568 (if (and bs--buffer-coming-from
569 (buffer-live-p bs--buffer-coming-from)
570 (not (memq bs--buffer-coming-from result)))
571 (setq result (cons bs--buffer-coming-from result)))
577 (bs-buffer-sort result))))
579 (defun bs-buffer-sort (buffer-list)
580 "Sort buffers in BUFFER-LIST according to `bs-buffer-sort-function'."
581 (if bs-buffer-sort-function
582 (sort buffer-list bs-buffer-sort-function)
583 buffer-list))
590 (bs-show-in-buffer (bs-buffer-list nil sort-description))
595 (defun bs--goto-current-buffer ()
596 "Goto line which represents the current buffer;
615 (format "Show buffer by configuration %S"
621 Aside from two header lines each line describes one buffer.
622 Move to a line representing the buffer you want to edit and select
623 buffer by \\[bs-select] or SPC. Abort buffer list with \\[bs-kill].
625 manipulating the buffer list and buffers.
628 \\[bs-select] or SPACE -- select current line's buffer and other marked buffers.
630 \\[bs-select-other-window] -- select current line's buffer in other window.
631 \\[bs-tmp-select-other-window] -- make another window display that buffer and
633 \\[bs-mouse-select] -- select current line's buffer and other marked buffers.
634 \\[bs-save] -- save current line's buffer immediately.
635 \\[bs-delete] -- kill current line's buffer immediately.
636 \\[bs-toggle-readonly] -- toggle read-only status of current line's buffer.
637 \\[bs-clear-modified] -- clear modified-flag on that buffer.
638 \\[bs-mark-current] -- mark current line's buffer to be displayed.
639 \\[bs-unmark-current] -- unmark current line's buffer to be displayed.
640 \\[bs-show-sorted] -- display buffer list sorted by next sort aspect.
647 \\[bs-set-current-buffer-to-show-always] -- mark current line's buffer \
649 \\[bs-visit-tags-table] -- call `visit-tags-table' on current line's buffer.
656 (buffer-disable-undo)
659 buffer-read-only t
672 "Let buffer disappear and reset window-configuration."
674 (bury-buffer (current-buffer))
696 "Change the height of the selected window to suit the current buffer list."
698 (fit-window-to-buffer (selected-window) bs-max-window-height)))
700 (defun bs--current-buffer ()
701 "Return buffer on current line.
702 Raise an error if not on a buffer line."
712 (let ((buffer (bs--current-buffer))
716 (bs--insert-one-entry buffer)
720 "View current line's buffer in View mode.
723 (view-buffer (bs--current-buffer)))
726 "Select current line's buffer and other marked buffers.
729 If there are marked buffers each marked buffer and the current line's buffer
733 (let ((buffer (bs--current-buffer)))
734 (bury-buffer (current-buffer))
736 (switch-to-buffer buffer)
739 (let* ((all (delq buffer bs--marked-buffers))
742 (switch-to-buffer buffer)
746 (switch-to-buffer (car all))
752 "Select current line's buffer by `switch-to-buffer-other-window'.
757 (let ((buffer (bs--current-buffer)))
758 (bury-buffer (current-buffer))
760 (switch-to-buffer-other-window buffer)))
763 "Make the other window select this line's buffer.
766 (let ((buffer (bs--current-buffer)))
767 (display-buffer buffer t)))
770 "Select current line's buffer in new created frame.
773 (let ((buffer (bs--current-buffer)))
774 (bury-buffer (current-buffer))
776 (switch-to-buffer-other-frame buffer)))
779 "Select selected line's buffer in new created frame.
787 "Select buffer on mouse click EVENT.
788 Select buffer by `bs-select'."
794 "Select current line's buffer in one window and delete other windows.
800 (defun bs-bury-buffer ()
801 "Bury buffer on current line."
803 (bury-buffer (bs--current-buffer))
807 "Save buffer on current line."
809 (let ((buffer (bs--current-buffer)))
811 (set-buffer buffer)
812 (save-buffer))
816 "Visit the tags table in the buffer on this line.
819 (let ((file (buffer-file-name (bs--current-buffer))))
822 (error "Specified buffer has no file"))))
825 "Toggle status of showing flag for buffer in current line."
827 (let ((buffer (bs--current-buffer))
830 (set-buffer buffer)
831 (setq res (cond ((null bs-buffer-show-mark)
833 ((eq bs-buffer-show-mark 'never)
836 (setq bs-buffer-show-mark res))
841 (defun bs-set-current-buffer-to-show-always (&optional not-to-show-p)
842 "Toggle status of buffer on line to `always shown'.
844 With no prefix argument the buffer on current line is marked to show
848 (bs-set-current-buffer-to-show-never)
849 (bs--set-toggle-to-show (bs--current-buffer) 'always)))
851 (defun bs-set-current-buffer-to-show-never ()
852 "Toggle status of buffer on line to `never shown'."
854 (bs--set-toggle-to-show (bs--current-buffer) 'never))
856 (defun bs--set-toggle-to-show (buffer what)
857 "Set value `bs-buffer-show-mark' of buffer BUFFER to WHAT.
859 the status of buffer on current line."
860 (with-current-buffer buffer (setq bs-buffer-show-mark what))
873 (let ((buffer (bs--current-buffer)))
874 (if buffer
875 (setq bs--marked-buffers (cons buffer bs--marked-buffers)))
888 (let ((buffer (bs--current-buffer)))
889 (if buffer
890 (setq bs--marked-buffers (delq buffer bs--marked-buffers)))
901 "Mark buffer to never be shown.")
902 (t "Mark buffer to show always."))))
905 "Kill buffer on current line."
907 (let ((current (bs--current-buffer))
909 (unless (kill-buffer current)
924 "Like `bs-delete' but go to buffer in front of current."
932 "Show buffer list sorted by buffer name."
938 (bs--goto-current-buffer)
963 (bs--goto-current-buffer)
967 "Toggle read-only status for buffer on current line.
970 (let ((buffer (bs--current-buffer)))
972 (set-buffer buffer)
977 "Set modified flag for buffer on current line to nil."
979 (let ((buffer (bs--current-buffer)))
981 (set-buffer buffer)
982 (set-buffer-modified-p nil)))
1001 If on top of buffer list go to last line."
1017 If at end of buffer list go to first line."
1022 (defun bs-visits-non-file (buffer)
1026 (not (buffer-file-name buffer)))
1028 (defun bs-sort-buffer-interns-are-last (b1 b2)
1030 (string-match "^\\*" (buffer-name b2)))
1040 `bs-buffer-sort-function'."
1045 bs-buffer-sort-function nil))
1051 bs-buffer-sort-function 'bs-sort-buffer-interns-are-last
1056 "Define a configuration for showing buffer *scratch* and file buffers."
1059 bs-buffer-sort-function 'bs-sort-buffer-interns-are-last
1062 ;; Show *scratch* buffer.
1075 (setq bs-buffer-sort-function 'bs-sort-buffer-interns-are-last))
1093 bs-buffer-sort-function (nth 5 list))
1125 "Apply next configuration START-NAME and refresh buffer list.
1136 (defun bs-show-in-buffer (list)
1137 "Display buffer list LIST in buffer *buffer-selection*.
1138 Select buffer *buffer-selection* and display buffers according to current
1139 configuration `bs-current-configuration'. Set window height, fontify buffer
1140 and move point to current buffer."
1142 (switch-to-buffer (get-buffer-create "*buffer-selection*"))
1146 (length (buffer-name entry))))
1149 (name-entry-length (min bs-maximal-buffer-name-column
1150 (max bs-minimal-buffer-name-column
1152 (erase-buffer)
1161 (bs--goto-current-buffer)
1162 (font-lock-fontify-buffer)
1164 (set-buffer-modified-p nil)))
1166 (defun bs-next-buffer (&optional buffer-list sorting-p)
1167 "Return next buffer and buffer list for buffer cycling in BUFFER-LIST.
1169 If BUFFER-LIST is nil the result of `bs-buffer-list' will be used as
1170 buffer list. The result is a cons of normally the second element of
1171 BUFFER-LIST and the buffer list used for buffer cycling."
1174 (bs-buffer-list (or buffer-list (bs-buffer-list))))
1175 (cons (or (car (cdr bs-buffer-list))
1176 (car bs-buffer-list)
1177 (current-buffer))
1178 bs-buffer-list)))
1180 (defun bs-previous-buffer (&optional buffer-list sorting-p)
1181 "Return previous buffer and buffer list for buffer cycling in BUFFER-LIST.
1183 If BUFFER-LIST is nil the result of `bs-buffer-list' will be used as
1184 buffer list. The result is a cons of last element of BUFFER-LIST and the
1185 buffer list used for buffer cycling."
1188 (bs-buffer-list (or buffer-list (bs-buffer-list))))
1189 (cons (or (car (last bs-buffer-list))
1190 (current-buffer))
1191 bs-buffer-list)))
1200 "Current buffer list used for cycling.")
1204 "Select next buffer defined by buffer cycling.
1205 The buffers taking part in buffer cycling are defined
1206 by buffer configuration `bs-cycle-configuration-name'."
1208 (let ((bs--buffer-coming-from (current-buffer))
1215 (let ((bs-buffer-sort-function nil)
1217 (let* ((tupel (bs-next-buffer (if (or (eq last-command
1226 (bury-buffer)
1227 (switch-to-buffer next)
1230 "this buffer"))))))
1234 "Select previous buffer defined by buffer cycling.
1235 The buffers taking part in buffer cycling are defined
1236 by buffer configuration `bs-cycle-configuration-name'."
1238 (let ((bs--buffer-coming-from (current-buffer))
1245 (let ((bs-buffer-sort-function nil)
1247 (let* ((tupel (bs-previous-buffer (if (or (eq last-command
1252 (prev-buffer (car tupel))
1256 (switch-to-buffer prev-buffer)
1259 "this buffer"))))))
1271 (defun bs--get-marked-string (start-buffer all-buffers)
1272 "Return a string which describes whether current buffer is marked.
1273 START-BUFFER is the buffer where we started buffer selection.
1274 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu.
1278 (cond ;; current buffer is the buffer we started buffer selection.
1279 ((eq (current-buffer) start-buffer)
1280 (if (memq (current-buffer) bs--marked-buffers)
1281 bs-string-current-marked ; buffer is marked
1283 ;; current buffer is marked
1284 ((memq (current-buffer) bs--marked-buffers)
1286 ;; current buffer hasn't a special mark.
1287 ((null bs-buffer-show-mark)
1289 ;; current buffer has a mark not to show itself.
1290 ((eq bs-buffer-show-mark 'never)
1292 ;; otherwise current buffer is marked to show always.
1296 (defun bs--get-modified-string (start-buffer all-buffers)
1297 "Return a string which describes whether current buffer is modified.
1298 START-BUFFER is the buffer where we started buffer selection.
1299 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1300 (if (buffer-modified-p) "*" " "))
1302 (defun bs--get-readonly-string (start-buffer all-buffers)
1303 "Return a string which describes whether current buffer is read only.
1304 START-BUFFER is the buffer where we started buffer selection.
1305 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1306 (if buffer-read-only "%" " "))
1308 (defun bs--get-size-string (start-buffer all-buffers)
1309 "Return a string which describes the size of current buffer.
1310 START-BUFFER is the buffer where we started buffer selection.
1311 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1312 (int-to-string (buffer-size)))
1314 (defun bs--get-name (start-buffer all-buffers)
1315 "Return name of current buffer for Buffer Selection Menu.
1316 The name of current buffer gets additional text properties
1318 START-BUFFER is the buffer where we started buffer selection.
1319 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1320 (propertize (buffer-name)
1321 'help-echo "mouse-2: select this buffer, mouse-3: select in other frame"
1324 (defun bs--get-mode-name (start-buffer all-buffers)
1325 "Return the name of mode of current buffer for Buffer Selection Menu.
1326 START-BUFFER is the buffer where we started buffer selection.
1327 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1330 (defun bs--get-file-name (start-buffer all-buffers)
1332 This is the variable `buffer-file-name' of current buffer.
1335 START-BUFFER is the buffer where we started buffer selection.
1336 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu."
1339 (or buffer-file-name ""))
1341 'help-echo "mouse-2: select this buffer, mouse-3: select in other frame"))
1343 (defun bs--insert-one-entry (buffer)
1344 "Generate one entry for buffer BUFFER in Buffer Selection Menu.
1346 and evaluates corresponding string. Inserts string in current buffer;
1347 normally *buffer-selection*."
1351 (apply-args (append (list bs--buffer-coming-from bs-current-list))))
1354 (set-buffer buffer)
1382 "Insert header for Buffer Selection Menu in current buffer."
1408 "Display buffer list of configuration with name NAME.
1410 Unless current buffer is buffer *buffer-selection* we have to save
1411 the buffer we started Buffer Selection Menu and the current window
1412 configuration to restore buffer and window configuration after a
1413 selection. If there is already a window displaying *buffer-selection*
1417 for buffer selection."
1420 (unless (string= "*buffer-selection*" (buffer-name))
1421 ;; Only when not in buffer *buffer-selection*
1422 ;; we have to set the buffer we started the command
1423 (setq bs--buffer-coming-from (current-buffer)))
1424 (let ((liste (bs-buffer-list))
1427 (string= (buffer-name (window-buffer w))
1428 "*buffer-selection*")))))
1437 (bs-show-in-buffer liste)
1441 "Convert prefix argument PREFIX-ARG to a name of a buffer configuration.
1468 "Make a menu of buffers so you can manipulate buffers or the buffer list.
1471 manipulating buffer list and buffers itself.
1472 User can move with [up] or [down], select a buffer
1476 With prefix argument ARG show a different buffer list. Function
1478 name of buffer configuration."