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

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

with-output-to-temp-buffer and let variable bindings


From: Stefan Reichör
Subject: with-output-to-temp-buffer and let variable bindings
Date: Wed, 05 Mar 2003 09:12:38 +0100
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.3.50 (windows-nt)

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
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:

Hi,
I use the latest emacs from CVS under windows.
I use bbdb and I found out, that the bbdb append feature does not
work with my emacs.
I tried the same feature on my debian box with the latest debian
emacs packages. It works on debian.

Here is the recipe for the test (in a bbdb buffer):
I type:
b search-string1 <RET>
+ b search-string2 <RET>

But the second search always clears the first one and I get only the
results of the second search.

On linux (emacs21.2.2) I get the correct result:
records with search-string1 and search-string2 are shown.


I started to debug the bbdb query.
Here is, what I found out:
* In the function bbdb-display-records-1, there is a call to
  with-output-to-temp-buffer.
* Before the call to this function, the variable bbdb-records
  contains the already visible bbdb-entries.
* After the call to with-output-to-temp-buffer, the variable
  bbdb-records is nil
  + On linux this variable has still the same value as before
  + I fixed the problem with the new variable xbbdb-records
* My question is now, is this a bug of with-output-to-temp-buffer?


My changed function looks like this:

(defun bbdb-display-records-1 (records &optional append layout)
  (setq append (or append (bbdb-append-records-p)))
  (if (or (null records)
          (consp (car records)))
      nil

    ;; add layout and a marker to the local list of records
    (setq layout (or layout bbdb-display-layout))
    (setq records (mapcar (lambda (x)
                            (list x layout (make-marker)))
                          records)))

  (let ((b (current-buffer))
        (temp-buffer-setup-hook nil)
        (temp-buffer-show-hook nil)
        (xbbdb-records (copy-alist bbdb-records))
        (first (car (car records))))
    ;;(message "xbbdb-records: %S" xbbdb-records)
    ;;(message "bbdb-records: %S" bbdb-records)

    ;;05.03.2003, XSteve, with-output-to-temp-buffer seems to
    ;; destroy the binding of bbdb-records on windows emacs, cvs version...
    ;; so use xbbdb-records - this works
    (with-output-to-temp-buffer bbdb-buffer-name
      (set-buffer bbdb-buffer-name)
      ;;(message "xbbdb-records: %S" xbbdb-records)
      ;;(message "bbdb-records: %S" bbdb-records)
      
      ;; If append is unset, clear the buffer.
      (unless append
        (bbdb-undisplay-records))

      ;; If we're appending these records to the ones already displayed,
      ;; then first remove any duplicates, and then sort them.
      (if append
          (let ((rest records))
            (while rest
              (if (assq (car (car rest)) xbbdb-records)
                  (setq records (delq (car rest) records)))
              (setq rest (cdr rest)))
            (setq records (append xbbdb-records records))
            (setq records
                  (sort records
                        (lambda (x y) (bbdb-record-lessp (car x) (car y)))))))
      (make-local-variable 'mode-line-buffer-identification)
      (make-local-variable 'mode-line-modified)
      (set (make-local-variable 'bbdb-showing-changed-ones) nil)
      (let ((done nil)
            (rest records)
            (changed (bbdb-changed-records)))
        (while (and rest (not done))
          (setq done (memq (car (car rest)) changed)
                rest (cdr rest)))
        (setq bbdb-showing-changed-ones done))
      (bbdb-frob-mode-line (length records))
      (and (not bbdb-gag-messages)
           (not bbdb-silent-running)
           (message "Formatting..."))
      (bbdb-mode)
      ;; this in in the *BBDB* buffer, remember, not the .bbdb buffer.
      (set (make-local-variable 'bbdb-records) nil)
      (setq bbdb-records records)
      (let ((buffer-read-only nil)
            prs)
        (bbdb-debug (setq prs (bbdb-records)))
        (setq truncate-lines t)
        (while records
          (bbdb-debug (if (not (memq (car (car records)) prs))
                          (error "record doubleplus unpresent!")))
          (set-marker (nth 2 (car records)) (point))
          (bbdb-format-record (nth 0 (car records))
                              (nth 1 (car records)))
          (setq records (cdr records))))
      (and (not bbdb-gag-messages)
           (not bbdb-silent-running)
           (message "Formatting...done."))
      )
    (set-buffer bbdb-buffer-name)
    (if (and append first)
        (let ((cons (assq first bbdb-records))
              (window (get-buffer-window (current-buffer))))
          (if window (set-window-start window (nth 2 cons)))))
    (bbdbq)
    ;; this doesn't really belong here, but it's convenient ... and when
    ;; using electric display it would not be called otherwise.
    (save-excursion (run-hooks 'bbdb-list-hook))
    (if bbdb-gui (bbdb-fontify-buffer))
    (set-buffer-modified-p nil)
    (setq buffer-read-only t)
    (set-buffer b)))



In GNU Emacs 21.3.50.1 (i386-msvc-nt5.0.2195)
 of 2003-02-19 on HEIDI
configured using `configure --with-msvc (12.00)'

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: DEA
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: t






reply via email to

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