From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lorentey@elte.hu (=?utf-8?Q?K=C3=A1roly_L=C5=91rentey?=) Newsgroups: gmane.emacs.devel Subject: Re: Buffer listing in multiple frames/ttys Date: Sun, 11 Dec 2005 17:53:21 +0100 Message-ID: References: <87wtinrypp.fsf@jurta.org> <87u0dqm5ta.fsf@jurta.org> <87pso9wvjo.fsf@jurta.org> <87d5k770y4.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1908859271==" X-Trace: sea.gmane.org 1134323907 23769 80.91.229.2 (11 Dec 2005 17:58:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Dec 2005 17:58:27 +0000 (UTC) Cc: Juri Linkov , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 11 18:58:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ElVS5-00066P-Pa for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2005 18:57:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ElVSX-0008O6-Kz for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2005 12:58:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ElURe-0002RS-3C for emacs-devel@gnu.org; Sun, 11 Dec 2005 11:53:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ElURc-0002Pm-Og for emacs-devel@gnu.org; Sun, 11 Dec 2005 11:53:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ElURa-0002PV-9E for emacs-devel@gnu.org; Sun, 11 Dec 2005 11:53:04 -0500 Original-Received: from [212.92.23.158] (helo=ninsei.hu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ElUT7-0003Py-K0; Sun, 11 Dec 2005 11:54:38 -0500 Original-Received: from walrus (walrus.inf.elte.hu [157.181.166.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by chatsubo.ninsei.hu (Postfix) with ESMTP id EF0FB1AC67; Sun, 11 Dec 2005 17:52:28 +0100 (CET) Original-Received: by walrus (Postfix, from userid 1000) id B0C181689D; Sun, 11 Dec 2005 17:53:25 +0100 (CET) Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Fri, 09 Dec 2005 10:04:37 -0500") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.52 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:47466 Archived-At: --===============1908859271== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Richard Stallman writes: > It could be an ordinary frame parameter, if only previous-buffer will > access it. But I don't like the idea of changing primitives such as > switch-to-buffer, bury-buffer, and kill-buffer. Not now. Below is an updated version of the patch without such low-level changes. If people find no problems, I'll install it on the CVS trunk. --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** orig/lisp/bindings.el --- mod/lisp/bindings.el *************** *** 338,366 **** (defvar mode-line-buffer-identification-keymap nil "\ Keymap for what is displayed by `mode-line-buffer-identification'.") - (defun last-buffer () "\ - Return the last non-hidden buffer in the buffer list." - ;; This logic is more or less copied from bury-buffer, - ;; except that we reverse the buffer list. - (let ((list (nreverse (buffer-list (selected-frame)))) - (pred (frame-parameter nil 'buffer-predicate)) - found notsogood) - (while (and list (not found)) - (unless (or (eq (aref (buffer-name (car list)) 0) ? ) - ;; If the selected frame has a buffer_predicate, - ;; disregard buffers that don't fit the predicate. - (and pred (not (funcall pred (car list))))) - (if (get-buffer-window (car list) 'visible) - (or notsogood (eq (car list) (current-buffer))) - (setq found (car list)))) - (pop list)) - (or found notsogood - (get-buffer "*scratch*") - (progn - (set-buffer-major-mode - (get-buffer-create "*scratch*")) - (get-buffer "*scratch*"))))) - (defun unbury-buffer () "\ Switch to the last buffer in the buffer list." (interactive) --- 338,343 ---- *************** *** 673,680 **** (define-key global-map [?\C-x right] 'next-buffer) (define-key global-map [?\C-x C-right] 'next-buffer) ! (define-key global-map [?\C-x left] 'prev-buffer) ! (define-key global-map [?\C-x C-left] 'prev-buffer) (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) --- 650,657 ---- (define-key global-map [?\C-x right] 'next-buffer) (define-key global-map [?\C-x C-right] 'next-buffer) ! (define-key global-map [?\C-x left] 'previous-buffer) ! (define-key global-map [?\C-x C-left] 'previous-buffer) (let ((map minibuffer-local-map)) (define-key map "\en" 'next-history-element) *** orig/lisp/menu-bar.el --- mod/lisp/menu-bar.el *************** *** 1662,1671 **** "Next Buffer" 'next-buffer :help "Switch to the \"next\" buffer in a cyclic order") ! (list 'prev-buffer 'menu-item "Previous Buffer" ! 'prev-buffer :help "Switch to the \"previous\" buffer in a cyclic order") (list 'select-named-buffer 'menu-item --- 1662,1671 ---- "Next Buffer" 'next-buffer :help "Switch to the \"next\" buffer in a cyclic order") ! (list 'previous-buffer 'menu-item "Previous Buffer" ! 'previous-buffer :help "Switch to the \"previous\" buffer in a cyclic order") (list 'select-named-buffer 'menu-item *** orig/lisp/simple.el --- mod/lisp/simple.el *************** *** 52,75 **** "Highlight (un)matching of parens and expressions." :group 'matching) (defun next-buffer () "Switch to the next buffer in cyclic order." (interactive) ! (let ((buffer (current-buffer))) ! (switch-to-buffer (other-buffer buffer)) ! (bury-buffer buffer))) ! (defun prev-buffer () "Switch to the previous buffer in cyclic order." (interactive) ! (let ((list (nreverse (buffer-list))) ! found) ! (while (and (not found) list) ! (let ((buffer (car list))) ! (if (and (not (get-buffer-window buffer)) ! (not (string-match "\\` " (buffer-name buffer)))) ! (setq found buffer))) ! (setq list (cdr list))) ! (switch-to-buffer found))) ;;; next-error support framework --- 52,118 ---- "Highlight (un)matching of parens and expressions." :group 'matching) + (defun get-next-valid-buffer (list &optional buffer visible-ok frame) "\ + Search LIST for a valid buffer to display in FRAME. + Return nil when all buffers in LIST are undesirable for display, + otherwise return the first suitable buffer in LIST. + + Buffers not visible in windows are preferred to visible buffers, + unless VISIBLE-OK is non-nil. + If the optional argument FRAME is nil, it defaults to the selected frame. + If BUFFER is non-nil, ignore occurances of that buffer in LIST." + ;; This logic is more or less copied from other-buffer. + (setq frame (or frame (selected-frame))) + (let ((pred (frame-parameter frame 'buffer-predicate)) + found buf) + (while (and (not found) list) + (setq buf (car list)) + (if (and (not (eq buffer buf)) + (buffer-live-p buf) + (or (null pred) (funcall pred buf)) + (not (eq (aref (buffer-name buf) 0) ?\s)) + (or visible-ok (null (get-buffer-window buf 'visible)))) + (setq found buf) + (setq list (cdr list)))) + (car list))) + + (defun last-buffer (&optional buffer visible-ok frame) "\ + Return the last non-hidden displayable buffer in the buffer list. + If BUFFER is non-nil, last-buffer will ignore that buffer. + Buffers not visible in windows are preferred to visible buffers, + unless optional argument VISIBLE-OK is non-nil. + If the optional third argument FRAME is non-nil, use that frame's + buffer list instead of the selected frame's buffer list. + If no other buffer exists, the buffer `*scratch*' is returned." + (setq frame (or frame (selected-frame))) + (or (get-next-valid-buffer (frame-parameter frame 'buried-buffer-list) + buffer visible-ok frame) + (get-next-valid-buffer (nreverse (buffer-list frame)) + buffer-visible-ok frame) + (progn + (set-buffer-major-mode (get-buffer-create "*scratch*")) + (get-buffer "*scratch*")))) + (defun next-buffer () "Switch to the next buffer in cyclic order." (interactive) ! (let ((buffer (current-buffer)) ! (bbl (frame-parameter nil 'buried-buffer-list))) ! (switch-to-buffer (other-buffer buffer t)) ! (bury-buffer buffer) ! (set-frame-parameter nil 'buried-buffer-list ! (cons buffer (delq buffer bbl))))) ! (defun previous-buffer () "Switch to the previous buffer in cyclic order." (interactive) ! (let ((buffer (last-buffer (current-buffer) t)) ! (bbl (frame-parameter nil 'buried-buffer-list))) ! (switch-to-buffer buffer) ! ;; Clean up buried-buffer-list up to and including the chosen buffer. ! (while (and bbl (not (eq (car bbl) buffer))) ! (setq bbl (cdr bbl))) ! (set-frame-parameter nil 'buried-buffer-list bbl))) ! ;;; next-error support framework --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =2D-=20 K=C3=A1roly --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBDnFmE6eoyqA+yej8RAuQJAJ9NN1lO7/YHCQAvb98Wr7ZL8IuFKgCgxZtH s81D5g0N47YhR0Q+jO6Q+5M= =57sF -----END PGP SIGNATURE----- --==-=-=-- --===============1908859271== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============1908859271==--