* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
[not found] <E1Tfocu-00056V-AU@vcs.savannah.gnu.org>
@ 2012-12-04 18:52 ` Stefan Monnier
2012-12-04 22:39 ` Katsumi Yamaoka
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-12-04 18:52 UTC (permalink / raw)
To: Katsumi Yamaoka; +Cc: emacs-devel
> +;; `flet' and `labels' got obsolete since Emacs 24.3.
> +(defmacro gmm-flet (bindings &rest body)
> + "Make temporary overriding function definitions.
> +
> +\(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
> + `(let (fn origs)
> + (dolist (bind ',bindings)
> + (setq fn (car bind))
> + (push (cons fn (and (fboundp fn) (symbol-function fn))) origs)
> + (fset fn (cons 'lambda (cdr bind))))
> + (unwind-protect
> + (progn ,@body)
> + (dolist (orig origs)
> + (if (cdr orig)
> + (fset (car orig) (cdr orig))
> + (fmakunbound (car orig)))))))
> +(put 'gmm-flet 'lisp-indent-function 1)
Nooooooooooooooo!!!!!!!!!
Please don't!
If you really can't stand the warning, then just do something like
(defmacro gmm-flet (&rest r)
(if (fboundp 'cl-flet) `(cl-flet ,@r) `(flet ,@r)))
After making sure that your uses of `flet' are compatible with `cl-flet'
and the other uses are changed to use something like (cl-)letf or
(better) defadvice.
Same for gmm-labels!
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-04 18:52 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros Stefan Monnier
@ 2012-12-04 22:39 ` Katsumi Yamaoka
2012-12-04 23:05 ` Katsumi Yamaoka
0 siblings, 1 reply; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-04 22:39 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
Stefan Monnier wrote:
>> +;; `flet' and `labels' got obsolete since Emacs 24.3.
>> +(defmacro gmm-flet (bindings &rest body)
[...]
> Nooooooooooooooo!!!!!!!!!
> Please don't!
[...]
> Same for gmm-labels!
Ok, I'll replace both so as to use cl-flet and cl-labels soon.
IIRC I didn't see neither cl-flet nor cl-letf wasn't usable as
an analogue to flet (I tried them right after flet was marked
obsolete). But now I confirmed it:
(progn (pp (macroexpand
'(cl-flet ((message (&rest args) (concat "X " (apply #'format args))))
(message "Hello"))
)) nil)
(let ((--cl-message--
(cl-function
(lambda (&rest args)
(concat "X " (apply #'format args))))))
(funcall --cl-message-- "Hello"))
OTHO, as for gmm-labels I was already using cl-labels in the
same way as you suggested for flet. But why I tried it so as
not to depend on cl was to try to reduce the ugliness of the way
cl handles the #'FUNC cases in a labels form.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-04 22:39 ` Katsumi Yamaoka
@ 2012-12-04 23:05 ` Katsumi Yamaoka
2012-12-05 0:14 ` Katsumi Yamaoka
2012-12-05 4:19 ` Stefan Monnier
0 siblings, 2 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-04 23:05 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
Katsumi Yamaoka wrote:
> IIRC I didn't see neither cl-flet nor cl-letf wasn't usable as
> an analogue to flet (I tried them right after flet was marked
> obsolete). But now I confirmed it:
> (progn (pp (macroexpand
> '(cl-flet ((message (&rest args) (concat "X " (apply #'format args))))
> (message "Hello"))
> )) nil)
> (let ((--cl-message--
> (cl-function
> (lambda (&rest args)
> (concat "X " (apply #'format args))))))
> (funcall --cl-message-- "Hello"))
No, it wasn't appropriate example. Again I confirmed we have no
replacement of flet.
(defun my-message ()
(message "Hello"))
(cl-flet ((message (&rest args) (concat "X " (apply #'format args))))
(my-message))
"Hello"
(flet ((message (&rest args) (concat "X " (apply #'format args))))
(my-message))
"X Hello"
Defadvice? Uhm, that defadvice code exists in an official source
code is very ugly, I feel. :<
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-04 23:05 ` Katsumi Yamaoka
@ 2012-12-05 0:14 ` Katsumi Yamaoka
2012-12-05 2:26 ` Katsumi Yamaoka
2012-12-05 4:19 ` Stefan Monnier
1 sibling, 1 reply; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-05 0:14 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
Katsumi Yamaoka wrote:
[...]
> No, it wasn't appropriate example. Again I confirmed we have no
> replacement of flet.
> (defun my-message ()
> (message "Hello"))
> (cl-flet ((message (&rest args) (concat "X " (apply #'format args))))
> (my-message))
> "Hello"
> (flet ((message (&rest args) (concat "X " (apply #'format args))))
> (my-message))
> "X Hello"
> Defadvice? Uhm, that defadvice code exists in an official source
> code is very ugly, I feel. :<
I've temporarily replaced it in this way:
(let ((orig-FUNCTION (symbol-function 'FUNCTION)))
(fet 'FUNCTION (lambda (arg) new definition))
(unwind-protect
(progn bla bla)
(fset 'FUNCTION orig-FUNCTION)))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-05 0:14 ` Katsumi Yamaoka
@ 2012-12-05 2:26 ` Katsumi Yamaoka
0 siblings, 0 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-05 2:26 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
Katsumi Yamaoka wrote:
> I've temporarily replaced it in this way:
> (let ((orig-FUNCTION (symbol-function 'FUNCTION)))
> (fet 'FUNCTION (lambda (arg) new definition))
> (unwind-protect
> (progn bla bla)
> (fset 'FUNCTION orig-FUNCTION)))
I learned how cl-letf works and re-introduced gmm-flet that works
like the old flet.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-04 23:05 ` Katsumi Yamaoka
2012-12-05 0:14 ` Katsumi Yamaoka
@ 2012-12-05 4:19 ` Stefan Monnier
2012-12-05 5:46 ` Katsumi Yamaoka
2012-12-05 19:29 ` Richard Stallman
1 sibling, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-12-05 4:19 UTC (permalink / raw)
To: Katsumi Yamaoka; +Cc: emacs-devel
> Defadvice? Uhm, that defadvice code exists in an official source
> code is very ugly, I feel. :<
The problem with defadvice is that it overrides functions. The letf
cases we're talking about also override functions, so they're just as
nasty as uses of defadvice. Worse, they don't even announce themselves
in the docstring and they often remove themselves before you get
a chance to see that some overriding is going on.
So, yes, I much prefer defadvice.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-05 4:19 ` Stefan Monnier
@ 2012-12-05 5:46 ` Katsumi Yamaoka
2012-12-05 19:29 ` Richard Stallman
1 sibling, 0 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-05 5:46 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel
Stefan Monnier wrote:
>> Defadvice? Uhm, that defadvice code exists in an official source
>> code is very ugly, I feel. :<
> The problem with defadvice is that it overrides functions. The letf
> cases we're talking about also override functions, so they're just as
> nasty as uses of defadvice.
Defadvice overrides functions lastingly but letf does it transiently.
Moreover defadvice makes it slow a bit even when it is unnecessary
to modify the behavior. Maybe this is another reason I don't prefer
using defadvice in an official source code. I don't want to make
generic functions worse by modifying only for particular users.
> Worse, they don't even announce themselves in the docstring and they
> often remove themselves before you get a chance to see that some
> overriding is going on.
> So, yes, I much prefer defadvice.
I agree to conceal what it does is nasty. The best thing I think
is to modify it permanently, rather than advising it, so as to be
able to switch the behavior for a certain purpose (unless the change
makes it regress). However, Gnus should run on many versions of
Emacsen, so there is a limit on modifying things in old Emacsen.
Therefore I believe using flet or cl-letf is the second best.
BTW, I have a plan to implement gmm-called-interactively-p.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-05 4:19 ` Stefan Monnier
2012-12-05 5:46 ` Katsumi Yamaoka
@ 2012-12-05 19:29 ` Richard Stallman
2012-12-05 19:35 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el(gmm-flet, " Drew Adams
2012-12-06 2:01 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, " Katsumi Yamaoka
1 sibling, 2 replies; 12+ messages in thread
From: Richard Stallman @ 2012-12-05 19:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: yamaoka, emacs-devel
The problem with defadvice is that it overrides functions. The letf
cases we're talking about also override functions, so they're just as
nasty as uses of defadvice. Worse, they don't even announce themselves
in the docstring and they often remove themselves before you get
a chance to see that some overriding is going on.
The reason it is bad for the Emacs sources to override functions in
the Emacs sources is that it makes for confusion in debugging. Thus
my decision many years ago that the Emacs sources should not contain
any advice for functions. I considered every use of defadvice in the
Emacs source code as a problem to be fixed. I did not fix them all,
only for lack of time.
I think the same argument applies to letf. So the Emacs sources
should not contain advice or letf.
Users can use these features -- the only people they might confuse
are themselves, and we can leave it up to them to decide whether to
take that risk. However, in our code, we should handle these
situations in other ways.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el(gmm-flet, gmm-labels): New macros.
2012-12-05 19:29 ` Richard Stallman
@ 2012-12-05 19:35 ` Drew Adams
2012-12-06 2:01 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, " Katsumi Yamaoka
1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2012-12-05 19:35 UTC (permalink / raw)
To: rms, 'Stefan Monnier'; +Cc: yamaoka, emacs-devel
> The problem with defadvice is that it overrides
> functions. The letf cases we're talking about also
> override functions, so they're just as nasty as uses
> of defadvice. Worse, they don't even announce themselves
> in the docstring and they often remove themselves before you get
> a chance to see that some overriding is going on.
>
> The reason it is bad for the Emacs sources to override functions in
> the Emacs sources is that it makes for confusion in debugging.
That is exactly the main reason I don't like to use defadvice too much in my own
code. Our debugger (I generally use `debug', not `edebug') digests it poorly
(not sure how it could do things much better, however).
There might be more important reasons to use or not to use defadvice, but
debugging confusion is a major reason I avoid it.
> Thus my decision many years ago that the Emacs sources should not
> contain any advice for functions. I considered every use of
> defadvice in the Emacs source code as a problem to be fixed.
> I did not fix them all, only for lack of time.
>
> I think the same argument applies to letf. So the Emacs sources
> should not contain advice or letf.
>
> Users can use these features -- the only people they might confuse
> are themselves, and we can leave it up to them to decide whether to
> take that risk. However, in our code, we should handle these
> situations in other ways.
Makes sense to me.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-05 19:29 ` Richard Stallman
2012-12-05 19:35 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el(gmm-flet, " Drew Adams
@ 2012-12-06 2:01 ` Katsumi Yamaoka
2012-12-06 13:27 ` Stefan Monnier
2012-12-06 22:46 ` Richard Stallman
1 sibling, 2 replies; 12+ messages in thread
From: Katsumi Yamaoka @ 2012-12-06 2:01 UTC (permalink / raw)
To: rms; +Cc: monnier, emacs-devel
Richard Stallman wrote:
> I think the same argument applies to letf. So the Emacs sources
> should not contain advice or letf.
Ok, I will remove two Gnus codes that use letf from Emacs trunk.
It means increasing the differences between Gnus v5.13 (that of
Emacs) and Ma Gnus (a version that supports many Emacs versions)
a bit. Of course it doesn't mean removing all the things being
used to keep the compatibility with Emacs versions and XEmacs
versions, since it will make the developers hard to maintain
those Gnus versions.
In addition to this, also I have to modify the mailabbrev code
so that it may expand mail aliases in the minibuffer.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-06 2:01 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, " Katsumi Yamaoka
@ 2012-12-06 13:27 ` Stefan Monnier
2012-12-06 22:46 ` Richard Stallman
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-12-06 13:27 UTC (permalink / raw)
To: Katsumi Yamaoka; +Cc: rms, emacs-devel
> In addition to this, also I have to modify the mailabbrev code
> so that it may expand mail aliases in the minibuffer.
Whenever "you" need a letf/flet/advice override, you should accompany it
with a M-x report-emacs-bug requesting some change to make it unneeded.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros.
2012-12-06 2:01 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, " Katsumi Yamaoka
2012-12-06 13:27 ` Stefan Monnier
@ 2012-12-06 22:46 ` Richard Stallman
1 sibling, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2012-12-06 22:46 UTC (permalink / raw)
To: Katsumi Yamaoka; +Cc: monnier, emacs-devel
Ok, I will remove two Gnus codes that use letf from Emacs trunk.
Please look for another way to write that code! Maybe Emacs needs
some additional hooks so that you can do what you want to do
in a clean way.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-12-06 22:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1Tfocu-00056V-AU@vcs.savannah.gnu.org>
2012-12-04 18:52 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, gmm-labels): New macros Stefan Monnier
2012-12-04 22:39 ` Katsumi Yamaoka
2012-12-04 23:05 ` Katsumi Yamaoka
2012-12-05 0:14 ` Katsumi Yamaoka
2012-12-05 2:26 ` Katsumi Yamaoka
2012-12-05 4:19 ` Stefan Monnier
2012-12-05 5:46 ` Katsumi Yamaoka
2012-12-05 19:29 ` Richard Stallman
2012-12-05 19:35 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el(gmm-flet, " Drew Adams
2012-12-06 2:01 ` [Emacs-diffs] /srv/bzr/emacs/trunk r111086: gmm-utils.el (gmm-flet, " Katsumi Yamaoka
2012-12-06 13:27 ` Stefan Monnier
2012-12-06 22:46 ` Richard Stallman
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.