Mercurial > emacs
comparison lisp/bs.el @ 90288:7432ca837c8d
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-9
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 16-33)
- Update from CVS
- Install ERC.
- Fix ERC compiler warnings.
- Use utf-8 encoding in ERC ChangeLogs.
- Merge ERC-related Viper hacks into Viper.
- Merge from erc--main--0
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 8-13)
- Merge from emacs--devo--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 01 Feb 2006 10:07:17 +0000 |
parents | a3716f7538f2 6ede67948264 |
children | c5406394f567 |
comparison
equal
deleted
inserted
replaced
90287:3cd97358d81a | 90288:7432ca837c8d |
---|---|
177 The function gets as parameter the buffer where we have started | 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 | 178 buffer selection and the list of all buffers to show. The function must |
179 return a string representing the column's value." | 179 return a string representing the column's value." |
180 :group 'bs-appearance | 180 :group 'bs-appearance |
181 :type '(repeat sexp)) | 181 :type '(repeat sexp)) |
182 | |
183 (defvar bs--running-in-xemacs (string-match "XEmacs" (emacs-version)) | |
184 "Non-nil when running under XEmacs.") | |
185 | 182 |
186 (defun bs--make-header-match-string () | 183 (defun bs--make-header-match-string () |
187 "Return a regexp matching the first line of a Buffer Selection Menu buffer." | 184 "Return a regexp matching the first line of a Buffer Selection Menu buffer." |
188 (let ((res "^\\(") | 185 (let ((res "^\\(") |
189 (ele bs-attributes-list)) | 186 (ele bs-attributes-list)) |
699 window)) | 696 window)) |
700 | 697 |
701 (defun bs--set-window-height () | 698 (defun bs--set-window-height () |
702 "Change the height of the selected window to suit the current buffer list." | 699 "Change the height of the selected window to suit the current buffer list." |
703 (unless (one-window-p t) | 700 (unless (one-window-p t) |
704 (shrink-window (- (window-height (selected-window)) | 701 (fit-window-to-buffer (selected-window) bs-max-window-height))) |
705 ;; window-height in xemacs includes mode-line | |
706 (+ (if bs--running-in-xemacs 3 1) | |
707 bs-header-lines-length | |
708 (min (length bs-current-list) | |
709 bs-max-window-height)))))) | |
710 | 702 |
711 (defun bs--current-buffer () | 703 (defun bs--current-buffer () |
712 "Return buffer on current line. | 704 "Return buffer on current line. |
713 Raise an error if not on a buffer line." | 705 Raise an error if not on a buffer line." |
714 (beginning-of-line) | 706 (beginning-of-line) |
1009 | 1001 |
1010 (defun bs--up () | 1002 (defun bs--up () |
1011 "Move cursor vertically up one line. | 1003 "Move cursor vertically up one line. |
1012 If on top of buffer list go to last line." | 1004 If on top of buffer list go to last line." |
1013 (interactive "p") | 1005 (interactive "p") |
1014 (previous-line 1) | 1006 (if (> (count-lines 1 (point)) bs-header-lines-length) |
1015 (if (<= (count-lines 1 (point)) (1- bs-header-lines-length)) | 1007 (forward-line -1) |
1016 (progn | 1008 (goto-char (point-max)) |
1017 (goto-char (point-max)) | 1009 (beginning-of-line) |
1018 (beginning-of-line) | 1010 (recenter -1))) |
1019 (recenter -1)) | |
1020 (beginning-of-line))) | |
1021 | 1011 |
1022 (defun bs-down (arg) | 1012 (defun bs-down (arg) |
1023 "Move cursor vertically down ARG lines in Buffer Selection Menu." | 1013 "Move cursor vertically down ARG lines in Buffer Selection Menu." |
1024 (interactive "p") | 1014 (interactive "p") |
1025 (if (and arg (numberp arg) (< arg 0)) | 1015 (if (and arg (numberp arg) (< arg 0)) |
1027 (bs--nth-wrapper arg 'bs--down))) | 1017 (bs--nth-wrapper arg 'bs--down))) |
1028 | 1018 |
1029 (defun bs--down () | 1019 (defun bs--down () |
1030 "Move cursor vertically down one line. | 1020 "Move cursor vertically down one line. |
1031 If at end of buffer list go to first line." | 1021 If at end of buffer list go to first line." |
1032 (let ((last (line-end-position))) | 1022 (if (eq (line-end-position) (point-max)) |
1033 (if (eq last (point-max)) | 1023 (goto-line (1+ bs-header-lines-length)) |
1034 (goto-line (1+ bs-header-lines-length)) | 1024 (forward-line 1))) |
1035 (next-line 1)))) | |
1036 | 1025 |
1037 (defun bs-visits-non-file (buffer) | 1026 (defun bs-visits-non-file (buffer) |
1038 "Return t or nil whether BUFFER visits no file. | 1027 "Return t or nil whether BUFFER visits no file. |
1039 A value of t means BUFFER belongs to no file. | 1028 A value of t means BUFFER belongs to no file. |
1040 A value of nil means BUFFER belongs to a file." | 1029 A value of nil means BUFFER belongs to a file." |
1330 "Return name of current buffer for Buffer Selection Menu. | 1319 "Return name of current buffer for Buffer Selection Menu. |
1331 The name of current buffer gets additional text properties | 1320 The name of current buffer gets additional text properties |
1332 for mouse highlighting. | 1321 for mouse highlighting. |
1333 START-BUFFER is the buffer where we started buffer selection. | 1322 START-BUFFER is the buffer where we started buffer selection. |
1334 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu." | 1323 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu." |
1335 (let ((name (copy-sequence (buffer-name)))) | 1324 (propertize (buffer-name) |
1336 (add-text-properties | 1325 'help-echo "mouse-2: select this buffer, mouse-3: select in other frame" |
1337 0 (length name) | 1326 'mouse-face 'highlight)) |
1338 '(mouse-face highlight | |
1339 help-echo | |
1340 "mouse-2: select this buffer, mouse-3: select in other frame") | |
1341 name) | |
1342 (if (< (length name) bs--name-entry-length) | |
1343 (concat name | |
1344 (make-string (- bs--name-entry-length (length name)) ? )) | |
1345 name))) | |
1346 | 1327 |
1347 (defun bs--get-mode-name (start-buffer all-buffers) | 1328 (defun bs--get-mode-name (start-buffer all-buffers) |
1348 "Return the name of mode of current buffer for Buffer Selection Menu. | 1329 "Return the name of mode of current buffer for Buffer Selection Menu. |
1349 START-BUFFER is the buffer where we started buffer selection. | 1330 START-BUFFER is the buffer where we started buffer selection. |
1350 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu." | 1331 ALL-BUFFERS is the list of buffer appearing in Buffer Selection Menu." |
1397 string)) | 1378 string)) |
1398 | 1379 |
1399 (defun bs--format-aux (string align len) | 1380 (defun bs--format-aux (string align len) |
1400 "Generate a string with STRING with alignment ALIGN and length LEN. | 1381 "Generate a string with STRING with alignment ALIGN and length LEN. |
1401 ALIGN is one of the symbols `left', `middle', or `right'." | 1382 ALIGN is one of the symbols `left', `middle', or `right'." |
1402 (let ((length (length string))) | 1383 (let* ((width (length string)) |
1403 (if (>= length len) | 1384 (len (max len width))) |
1404 string | 1385 (format (format "%%%s%ds" (if (eq align 'right) "" "-") len) |
1405 (if (eq 'right align) | 1386 (if (eq align 'middle) |
1406 (concat (make-string (- len length) ? ) string) | 1387 (concat (make-string (/ (- len width) 2) ?\s) string) |
1407 (concat string (make-string (- len length) ? )))))) | 1388 string)))) |
1408 | 1389 |
1409 (defun bs--show-header () | 1390 (defun bs--show-header () |
1410 "Insert header for Buffer Selection Menu in current buffer." | 1391 "Insert header for Buffer Selection Menu in current buffer." |
1411 (mapcar '(lambda (string) | 1392 (mapcar '(lambda (string) |
1412 (insert string "\n")) | 1393 (insert string "\n")) |