[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: go to next unsaved buffer

From: Paul Stoeber
Subject: Re: go to next unsaved buffer
Date: Wed, 3 Jul 2002 12:16:53 +0000

On Wed, Jul 03, 2002 at 01:30:16PM +0800, Dan Jacobson wrote:
> Paul> `save-some-buffers' already has this: C-r.  Type C-M-c to exit from
> Paul> the recursive edit.
> It is a bug that C-h k C-x s does not mention this.

The prompt "Save file /tmp/1? (y, n, !, ., q, C-r or C-h)"
mentions C-r, and C-h explains it.

> By the way I just tired what you mentioned.  Seems like a great way to
> get all confused.  I ended up with lots of [[[ ]]] in the modeline and
> I had to hit exit-recursive-edit several times to get out.

C-r puts you into view-mode.  Does this cause the problem?
It can be turned off with M-x view-mode.

> Anyway, my
> idea is simpler in that you aren't under the gun of being in the
> middle of answering the question of saving each buffer.

I've tried your idea, and it's actually more comfortable than the
the dialog with `save-some-buffers'.

A problem is: what is an "unsaved buffer"?

;; This function should be factored out of `save-some-buffers',
;; which is a moving target (see the thread
;; "address@hidden: modeline doesn't divulge buffer will go bye bye]"
;; on emacs-devel).
(defun buffer-unsaved-p (buffer)
  "The definition of \"unsaved buffer\" for `switch-to-next-unsaved-buffer'."
  (and (buffer-modified-p buffer)
       (or (buffer-file-name buffer)
           (not (string-match "\\`[ *]" (buffer-name buffer))))))

(defun switch-to-next-unsaved-buffer ()
  "Switch to next unsaved buffer if any.
The function `buffer-unsaved-p' defines \"unsaved buffer\"."
  (catch 'return
    (if (buffer-unsaved-p (current-buffer))
        (bury-buffer (current-buffer)))
    (dolist (buffer (buffer-list))
      (if (buffer-unsaved-p buffer)
          (if (eq buffer (current-buffer))
              (error "No other unsaved buffers")
            (switch-to-buffer buffer)
            (throw 'return nil))))
    (error "No unsaved buffers")))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]