X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e2f51f38c3626e888a81cc77834596c542a71731..ddce73d32fa3e62e022842e3bbdc0aa83bb358cc:/lisp/bs.el diff --git a/lisp/bs.el b/lisp/bs.el index 95dc371e57..5e9c6908f2 100644 --- a/lisp/bs.el +++ b/lisp/bs.el @@ -1,6 +1,6 @@ ;;; bs.el --- menu for selecting and displaying buffers -*- lexical-binding: t -*- -;; Copyright (C) 1998-2011 Free Software Foundation, Inc. +;; Copyright (C) 1998-2014 Free Software Foundation, Inc. ;; Author: Olaf Sylvester ;; Maintainer: Olaf Sylvester ;; Keywords: convenience @@ -25,7 +25,7 @@ ;; Version: 1.17 ;; X-URL: http://www.geekware.de/software/emacs ;; -;; The bs-package contains a main function bs-show for poping up a +;; The bs-package contains a main function bs-show for popping up a ;; buffer in a way similar to `list-buffers' and `electric-buffer-list': ;; The new buffer offers a Buffer Selection Menu for manipulating ;; the buffer list and buffers. @@ -124,8 +124,6 @@ ;;; Code: -(eval-when-compile (require 'cl)) - ;; ---------------------------------------------------------------------- ;; Globals for customization ;; ---------------------------------------------------------------------- @@ -338,15 +336,13 @@ Used internally, only.") ;; Internal globals ;; ---------------------------------------------------------------------- -(defvar bs-buffer-show-mark nil +(defvar-local bs-buffer-show-mark nil "Flag for the current mode for showing this buffer. A value of nil means buffer will be shown depending on the current configuration. A value of `never' means to never show the buffer. A value of `always' means to show buffer regardless of the configuration.") -(make-variable-buffer-local 'bs-buffer-show-mark) - ;; Make face named region (for XEmacs) (unless (facep 'region) (make-face 'region) @@ -618,7 +614,7 @@ Used from `window-size-change-functions'." (put 'bs-mode 'mode-class 'special) (define-derived-mode bs-mode nil "Buffer-Selection-Menu" - "Major mode for editing a subset of Emacs' buffers. + "Major mode for editing a subset of Emacs's buffers. \\ Aside from two header lines each line describes one buffer. Move to a line representing the buffer you want to edit and select @@ -650,17 +646,14 @@ available Buffer Selection Menu configuration. to show always. \\[bs-visit-tags-table] -- call `visit-tags-table' on current line's buffer. \\[bs-help] -- display this help text." - (make-local-variable 'font-lock-defaults) - (make-local-variable 'font-lock-verbose) - (make-local-variable 'font-lock-global-modes) (buffer-disable-undo) (setq buffer-read-only t truncate-lines t - show-trailing-whitespace nil - font-lock-global-modes '(not bs-mode) - font-lock-defaults '(bs-mode-font-lock-keywords t) - font-lock-verbose nil) - (set (make-local-variable 'revert-buffer-function) 'bs-refresh) + show-trailing-whitespace nil) + (setq-local font-lock-defaults '(bs-mode-font-lock-keywords t)) + (setq-local font-lock-verbose nil) + (setq-local font-lock-global-modes '(not bs-mode)) + (setq-local revert-buffer-function 'bs-refresh) (add-hook 'window-size-change-functions 'bs--track-window-changes) (add-hook 'kill-buffer-hook 'bs--remove-hooks nil t) (add-hook 'change-major-mode-hook 'bs--remove-hooks nil t)) @@ -830,10 +823,10 @@ See `visit-tags-table'." (interactive) (let ((res (with-current-buffer (bs--current-buffer) - (setq bs-buffer-show-mark (case bs-buffer-show-mark - ((nil) 'never) - ((never) 'always) - (t nil)))))) + (setq bs-buffer-show-mark (pcase bs-buffer-show-mark + (`nil 'never) + (`never 'always) + (_ nil)))))) (bs--update-current-line) (bs--set-window-height) (bs--show-config-message res))) @@ -961,10 +954,10 @@ Default is `bs--current-sort-function'." (defun bs-toggle-readonly () "Toggle read-only status for buffer on current line. -Uses function `toggle-read-only'." +Uses function `read-only-mode'." (interactive) (with-current-buffer (bs--current-buffer) - (toggle-read-only)) + (read-only-mode 'toggle)) (bs--update-current-line)) (defun bs-clear-modified () @@ -1150,7 +1143,7 @@ and move point to current buffer." (delete-char -1) (bs--set-window-height) (bs--goto-current-buffer) - (font-lock-fontify-buffer) + (font-lock-ensure) (bs-apply-sort-faces) (set-buffer-modified-p nil))) @@ -1212,11 +1205,10 @@ by buffer configuration `bs-cycle-configuration-name'." bs--cycle-list))) (next (car tupel)) (cycle-list (cdr tupel))) - (unless (window-dedicated-p (selected-window)) - ;; We don't want the frame iconified if the only window in the frame - ;; happens to be dedicated; let's get the error from switch-to-buffer - (bury-buffer)) - (switch-to-buffer next) + ;; We don't want the frame iconified if the only window in the frame + ;; happens to be dedicated. + (bury-buffer (current-buffer)) + (switch-to-buffer next nil t) (setq bs--cycle-list (append (cdr cycle-list) (list (car cycle-list)))) (bs-message-without-log "Next buffers: %s" @@ -1245,7 +1237,7 @@ by buffer configuration `bs-cycle-configuration-name'." bs--cycle-list))) (prev-buffer (car tupel)) (cycle-list (cdr tupel))) - (switch-to-buffer prev-buffer) + (switch-to-buffer prev-buffer nil t) (setq bs--cycle-list (append (last cycle-list) (reverse (cdr (reverse cycle-list))))) (bs-message-without-log "Previous buffers: %s" @@ -1414,9 +1406,9 @@ for buffer selection." (select-window active-window) (bs--restore-window-config) (setq bs--window-config-coming-from (current-window-configuration)) - (when (> (window-height (selected-window)) 7) - (split-window-vertically) - (other-window 1))) + (when (> (window-height) 7) + ;; Errors would mess with the window configuration (bug#10882). + (ignore-errors (select-window (split-window-below))))) (bs-show-in-buffer liste) (bs-message-without-log "%s" (bs--current-config-message)))))