emacs-pretest-bug
[Top][All Lists]
Advanced

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

get-next-valid-buffer should take an optional predicate argument


From: sabetts
Subject: get-next-valid-buffer should take an optional predicate argument
Date: Thu, 21 Sep 2006 17:03:41 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the address@hidden mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

It seems a common thing to do is to search the buffer list for the
last buffer that matches a predicate function. So here's a
modification to get-next-valid-buffer that adds that.

(defun get-next-valid-buffer (list &optional buffer visible-ok frame predicate)
  "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 occurrences of that buffer in LIST.
if PREDICATE is non-nil, it should be a function that takes a
buffer as an argument. Ignore buffers PREDICATE returns nil for."
  ;; This logic is more or less copied from other-buffer.
  (setq frame (or frame (selected-frame)))
  (let ((frame-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 frame-pred) (funcall frame-pred buf))
               (not (eq (aref (buffer-name buf) 0) ?\s))
               (or visible-ok (null (get-buffer-window buf 'visible)))
               (or (null predicate) (funcall predicate buf)))
          (setq found buf)
        (setq list (cdr list))))
    (car list)))


If emacs crashed, and you have the emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/local/share/emacs/22.0.50/etc/DEBUG for instructions.


In GNU Emacs 22.0.50.1 (powerpc-apple-darwin7.9.0)
 of 2006-09-08 on sabetts-Computer.local
X server distributor `Apple Computers', version 10.3.9
configured using `configure '--prefix=/usr/local' '--with-carbon' '--without-x' 
'--oldincludedir=/Developer/SDKs/MacOSX10.2.8.sdk/usr/include' 
'CPPFLAGS=-isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: iso-8859-1
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  compilation-in-progress: (grep)
  auto-image-file-mode: t
  shell-dirtrack-mode: t
  encoded-kbd-mode: t
  display-time-mode: t
  show-paren-mode: t
  rcirc-track-minor-mode: t
  iswitchb-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
C-n C-n C-M-f <return> <tab> ( o r SPC ( n u l l SPC 
p r e d i c a t e ) SPC ( f u n c a l l SPC p r e d 
i c a t e SPC b u f C-e ) ) C-a C-x C-s C-M-a C-SPC 
C-M-e M-w M-x b u g - <tab> <backspace> <tab> <backspace> 
<backspace> <backspace> C-g C-x b C-s C-s <return> 
C-x b <return> M-x r e p <tab> o r t <tab> b u <tab> 
<backspace> <backspace> <tab> e m <tab> b u <tab> 
<return>

Recent messages:
Auto-saving simple.el.gz: Opening output file: permission denied, 
/usr/local/share/emacs/22.0.50/lisp/#simple.el.gz#
Auto-saving...done
Saving file /usr/local/share/emacs/22.0.50/lisp/simple.el.gz...
Cannot write backup file; backing up in %backup%~
compressing simple.el.gz...done
Wrote /usr/local/share/emacs/22.0.50/lisp/simple.el.gz
Mark set [3 times]
Quit
Making completion list... [2 times]
Loading emacsbug...done




reply via email to

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