Commit ca6b8248 authored by Juanma Barranquero's avatar Juanma Barranquero
Browse files

Allow non-default values of `bs-header-lines-length'.

(bs--running-in-xemacs): Remove (not used anymore).
(bs--set-window-height): Simplify by using `fit-window-to-buffer' instead of
`shrink-window', thus avoiding having to compute the height of the window.
(bs--up): Wrap around even when there's no header.
(bs--down): Use `forward-line' instead of `next-line'.
parent 448541bc
...@@ -180,9 +180,6 @@ return a string representing the column's value." ...@@ -180,9 +180,6 @@ return a string representing the column's value."
:group 'bs-appearance :group 'bs-appearance
:type '(repeat sexp)) :type '(repeat sexp))
(defvar bs--running-in-xemacs (string-match "XEmacs" (emacs-version))
"Non-nil when running under XEmacs.")
(defun bs--make-header-match-string () (defun bs--make-header-match-string ()
"Return a regexp matching the first line of a Buffer Selection Menu buffer." "Return a regexp matching the first line of a Buffer Selection Menu buffer."
(let ((res "^\\(") (let ((res "^\\(")
...@@ -701,12 +698,7 @@ Return nil if there is no such buffer." ...@@ -701,12 +698,7 @@ Return nil if there is no such buffer."
(defun bs--set-window-height () (defun bs--set-window-height ()
"Change the height of the selected window to suit the current buffer list." "Change the height of the selected window to suit the current buffer list."
(unless (one-window-p t) (unless (one-window-p t)
(shrink-window (- (window-height (selected-window)) (fit-window-to-buffer (selected-window) bs-max-window-height)))
;; window-height in xemacs includes mode-line
(+ (if bs--running-in-xemacs 3 1)
bs-header-lines-length
(min (length bs-current-list)
bs-max-window-height))))))
(defun bs--current-buffer () (defun bs--current-buffer ()
"Return buffer on current line. "Return buffer on current line.
...@@ -1011,13 +1003,11 @@ Uses function `vc-toggle-read-only'." ...@@ -1011,13 +1003,11 @@ Uses function `vc-toggle-read-only'."
"Move cursor vertically up one line. "Move cursor vertically up one line.
If on top of buffer list go to last line." If on top of buffer list go to last line."
(interactive "p") (interactive "p")
(previous-line 1) (if (> (count-lines 1 (point)) bs-header-lines-length)
(if (<= (count-lines 1 (point)) (1- bs-header-lines-length)) (forward-line -1)
(progn (goto-char (point-max))
(goto-char (point-max)) (beginning-of-line)
(beginning-of-line) (recenter -1)))
(recenter -1))
(beginning-of-line)))
(defun bs-down (arg) (defun bs-down (arg)
"Move cursor vertically down ARG lines in Buffer Selection Menu." "Move cursor vertically down ARG lines in Buffer Selection Menu."
...@@ -1029,10 +1019,9 @@ If on top of buffer list go to last line." ...@@ -1029,10 +1019,9 @@ If on top of buffer list go to last line."
(defun bs--down () (defun bs--down ()
"Move cursor vertically down one line. "Move cursor vertically down one line.
If at end of buffer list go to first line." If at end of buffer list go to first line."
(let ((last (line-end-position))) (if (eq (line-end-position) (point-max))
(if (eq last (point-max)) (goto-line (1+ bs-header-lines-length))
(goto-line (1+ bs-header-lines-length)) (forward-line 1)))
(next-line 1))))
(defun bs-visits-non-file (buffer) (defun bs-visits-non-file (buffer)
"Return t or nil whether BUFFER visits no file. "Return t or nil whether BUFFER visits no file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment