From: Daniel Pfeiffer Date: Sun, 17 Oct 2004 08:35:10 +0000 (+0000) Subject: (Buffer-menu-revert-function): Emulate save-excursion. X-Git-Tag: ttn-vms-21-2-B4~4516 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bfb2dda4b668e09725234066cc2fea6c9c853682;p=emacs.git (Buffer-menu-revert-function): Emulate save-excursion. (Buffer-menu-beginning): New helper function. (Buffer-menu-execute): Use it. (Buffer-menu-select): Use it. (Buffer-menu-sort): Use it and also keep markers. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bab189e9615..a8a0b1776fc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2004-10-17 Daniel Pfeiffer + + * buff-menu.el (Buffer-menu-revert-function): Emulate save-excursion. + (Buffer-menu-beginning): New helper function. + (Buffer-menu-execute): Use it. + (Buffer-menu-select): Use it. + (Buffer-menu-sort): Use it and also keep markers. + 2004-10-17 Richard M. Stallman * paths.el (news-directory): Renamed from news-path. Old name alias. @@ -24,7 +32,7 @@ * help-at-pt.el (help-at-pt-unload-hook): Use add-hook; no defvar. - * frame.el (special-display-popup-frame): + * frame.el (special-display-popup-frame): Make the buffer current as its frame is created. * delsel.el (delsel-unload-hook): Set as a variable. diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 33a8c3ec3f5..b00721e93ec 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -197,9 +197,15 @@ Letters do not insert themselves; instead, they are commands. (defun Buffer-menu-revert-function (ignore1 ignore2) ;; We can not use save-excursion here. The buffer gets erased. - (let ((old-point (point))) + (let ((ocol (current-column)) + (oline (progn (move-to-column 4) + (get-text-property (point) 'buffer))) + (prop (point-min))) (list-buffers-noselect Buffer-menu-files-only) - (goto-char old-point))) + (while (setq prop (next-single-property-change prop 'buffer)) + (when (eq (get-text-property prop 'buffer) oline) + (goto-char prop) + (move-to-column ocol))))) (defun Buffer-menu-toggle-files-only (arg) "Toggle whether the current buffer-menu displays only file buffers. @@ -354,13 +360,16 @@ and then move up one line. Prefix arg means move that many lines." (delete-char 1) (insert (if arg ?* ? )))))) +(defun Buffer-menu-beginning () + (goto-char (point-min)) + (unless Buffer-menu-use-header-line + (forward-line))) + (defun Buffer-menu-execute () "Save and/or delete buffers marked with \\\\[Buffer-menu-save] or \\\\[Buffer-menu-delete] commands." (interactive) (save-excursion - (goto-char (point-min)) - (unless Buffer-menu-use-header-line - (forward-line 1)) + (Buffer-menu-beginning) (while (re-search-forward "^..S" nil t) (let ((modp nil)) (save-excursion @@ -371,9 +380,7 @@ and then move up one line. Prefix arg means move that many lines." (delete-char -1) (insert (if modp ?* ? )))))) (save-excursion - (goto-char (point-min)) - (unless Buffer-menu-use-header-line - (forward-line 1)) + (Buffer-menu-beginning) (let ((buff-menu-buffer (current-buffer)) (buffer-read-only nil)) (while (re-search-forward "^D" nil t) @@ -399,9 +406,7 @@ in the selected frame." (menu (current-buffer)) (others ()) tem) - (goto-char (point-min)) - (unless Buffer-menu-use-header-line - (forward-line 1)) + (Buffer-menu-beginning) (while (re-search-forward "^>" nil t) (setq tem (Buffer-menu-buffer t)) (let ((buffer-read-only nil)) @@ -581,7 +586,35 @@ For more information, see the function `buffer-menu'." (if (< column 2) (setq column 2)) (if (> column 5) (setq column 5))) (setq Buffer-menu-sort-column column) - (Buffer-menu-revert)) + (let (buffer-read-only l buf m1 m2) + (save-excursion + (Buffer-menu-beginning) + (while (not (eobp)) + (when (buffer-live-p (setq buf (get-text-property (+ (point) 4) 'buffer))) + (setq m1 (char-after) + m1 (if (memq m1 '(?> ?D)) m1) + m2 (char-after (+ (point) 2)) + m2 (if (eq m2 ?S) m2)) + (if (or m1 m2) + (push (list buf m1 m2) l))) + (forward-line))) + (Buffer-menu-revert) + (setq buffer-read-only) + (save-excursion + (Buffer-menu-beginning) + (while (not (eobp)) + (when (setq buf (assq (get-text-property (+ (point) 4) 'buffer) l)) + (setq m1 (cadr buf) + m2 (cadr (cdr buf))) + (when m1 + (delete-char 1) + (insert m1) + (backward-char 1)) + (when m2 + (forward-char 2) + (delete-char 1) + (insert m2))) + (forward-line))))) (defun Buffer-menu-make-sort-button (name column) (if (equal column Buffer-menu-sort-column) (setq column nil))