[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16576: Binding `standard-output' to a function doesn't work -- funct
From: |
Eli Zaretskii |
Subject: |
bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage |
Date: |
Tue, 28 Jan 2014 17:59:20 +0200 |
> Date: Tue, 28 Jan 2014 10:09:08 +0100
> From: Anders Lindgren <andlind@gmail.com>
>
> emacs -Q
> Eval the following:
>
> (defvar bug-bind-output-str nil)
>
> (defun bug-bind-output-function (char)
> (setq bug-bind-output-str
> (concat bug-bind-output-str (list char))))
>
> (defun bug-bind-output-test ()
> (interactive)
> (let ((bug-bind-output-str "")
> (standard-output 'bug-bind-output-function)
> (s
> "(\\(co\\(?:mbine-after-change-calls\\|nd\\(?:ition-case\\(?:-unless-debug\\)?\\)?\\)\\|eval-\\(?:a\\(?:fter-load\\|nd-compile\\)\\|next-after-load\\|when\\(?:-compile\\)?\\)\\|i\\(?:f\\|nline\\)\\|l\\(?:ambda\\|et\\(?:\\*\\|rec\\)?\\)\\|p\\(?:case\\(?:-let\\*?\\)?\\|rog[*12nv]?\\)\\|save-\\(?:current-buffer\\|excursion\\|match-data\\|restriction\\|selected-window\\|window-excursion\\)\\|track-mouse\\|unwind-protect\\|w\\(?:hile\\(?:-no-input\\)?\\|ith-\\(?:c\\(?:a\\(?:\\(?:se\\|tegory\\)-table\\)\\|urrent-buffer\\)\\|demoted-errors\\|electric-help\\|local-quit\\|no-warnings\\|output-to-\\(?:string\\|temp-buffer\\)\\|s\\(?:elected-\\(?:frame\\|window\\)\\|ilent-modifications\\|yntax-table\\)\\|t\\(?:emp-\\(?:buffer\\|\\(?:fil\\|messag\\)e\\)\\|imeout\\(?:-handler\\)?\\)\\|wrapper-hook\\)\\)\\)\\>")
> s0)
> (prin1 s)
> bug-bind-output-str))
>
> Type this a number of times:
>
> M-x (bug-bind-output-test) RET
I think there's a bug in your test program. You let-bind
bug-bind-output-str, and print that local binding after you call
prin1. But your print function concatenates each character onto the
_global_ binding of bug-bind-output-str, so the result is not in your
local binding, it's in the global one.
If you change your program like this:
(defun bug-bind-output-test ()
(interactive)
(setq bug-bind-output-str "")
(let ((standard-output 'bug-bind-output-function)
(s
"(\\(co\\(?:mbine-after-change-calls\\|nd\\(?:ition-case\\(?:-unless-debug\\)?\\)?\\)\\|eval-\\(?:a\\(?:fter-load\\|nd-compile\\)\\|next-after-load\\|when\\(?:-compile\\)?\\)\\|i\\(?:f\\|nline\\)\\|l\\(?:ambda\\|et\\(?:\\*\\|rec\\)?\\)\\|p\\(?:case\\(?:-let\\*?\\)?\\|rog[*12nv]?\\)\\|save-\\(?:current-buffer\\|excursion\\|match-data\\|restriction\\|selected-window\\|window-excursion\\)\\|track-mouse\\|unwind-protect\\|w\\(?:hile\\(?:-no-input\\)?\\|ith-\\(?:c\\(?:a\\(?:\\(?:se\\|tegory\\)-table\\)\\|urrent-buffer\\)\\|demoted-errors\\|electric-help\\|local-quit\\|no-warnings\\|output-to-\\(?:string\\|temp-buffer\\)\\|s\\(?:elected-\\(?:frame\\|window\\)\\|ilent-modifications\\|yntax-table\\)\\|t\\(?:emp-\\(?:buffer\\|\\(?:fil\\|messag\\)e\\)\\|imeout\\(?:-handler\\)?\\)\\|wrapper-hook\\)\\)\\)\\>")
s0)
(prin1 s)
bug-bind-output-str))
i.e., work with the global binding, then the program works as
expected, AFAICS.
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Anders Lindgren, 2014/01/28
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage,
Eli Zaretskii <=
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Anders Lindgren, 2014/01/28
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Eli Zaretskii, 2014/01/28
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Anders Lindgren, 2014/01/28
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Eli Zaretskii, 2014/01/29
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Anders Lindgren, 2014/01/29
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Stefan Monnier, 2014/01/29
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Anders Lindgren, 2014/01/31
- bug#16576: Binding `standard-output' to a function doesn't work -- function sometimes called with garbage, Stefan Monnier, 2014/01/31