all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: 22317@debbugs.gnu.org
Cc: Katsumi Yamaoka <yamaoka@jpl.org>
Subject: bug#22317: 25.0.50; mh-e: wrong usage of cl-flet
Date: Thu, 14 Jan 2016 12:46:20 -0500	[thread overview]
Message-ID: <f737u0vytv.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <b4m1t9vfrmk.fsf@jpl.org> (Katsumi Yamaoka's message of "Wed, 06 Jan 2016 10:01:23 +0900")


mh-e-devel, FYI:

http://debbugs.gnu.org/22317

Katsumi Yamaoka wrote:

> Hi,
>
> mh-e uses Gnus functions to render MIME messages and uses the
> mh-cl-flet macro to modify some of them.  Currently mh-e always
> loads cl (see mh-acros.el), so both cl-flet and flet are available
> and mh-cl-flet will become cl-flet:
> ,----
> | ;; Emacs 24 renamed flet to cl-flet.
> | (defalias 'mh-cl-flet
> |   (if (fboundp 'cl-flet)
> |       'cl-flet
> |     'flet))
> `----
> However, cl-flet is quite unlike flet, IIUC.  For instance, if
> cl-flet is used, the mh-cl-flet code in mh-display-emphasis
> ,----
> | ;; (defun mh-display-emphasis ()
> | ;;   "Display graphical emphasis."
> | ;;   (when (and mh-graphical-emphasis-flag (mh-small-show-buffer-p))
> |        (mh-cl-flet
> |         ((article-goto-body ()))      ; shadow this function to do nothing
> |         (save-excursion
> |           (goto-char (point-min))
> |           (article-emphasize)))
> | ;;     ))
> `----
> will be expanded to
> ,----
> | (progn
> |   (save-excursion
> |     (goto-char (point-min))
> |     (article-emphasize)))
> `----
> whereas if flet is used, it will be expanded to:
> ,----
> | (let* ((vnew (cl-function (lambda nil
> |                           (cl-block article-goto-body))))
> |        (old (symbol-function 'article-goto-body)))
> |   (unwind-protect
> |       (progn
> |       (fset 'article-goto-body vnew)
> |       (save-excursion
> |         (goto-char (point-min))
> |         (article-emphasize)))
> |     (fset 'article-goto-body old)))
> `----
> Note that the former doesn't achieve the original target, i.e.,
> article-goto-body is not modified while running article-emphasize.
>
> I don't know how it damages the behavior of mh-e, but I think it
> should be fixed anyway.  If mh-e keeps loading cl as ever,
> mh-cl-flet can be:
>
> (defalias 'mh-cl-flet 'flet)
>
> Otherwise use this complete Emacs-Lisp style flet emulation macro
> (a copy of gmm-flet that exists in only the Gnus git master):
>
> --8<---------------cut here---------------start------------->8---
> (defmacro mh-cl-flet (bindings &rest body)
>   "Make temporary overriding function definitions.
> This is an analogue of a dynamically scoped `let' that operates on
> the function cell of FUNCs rather than their value cell.
>
> \(fn ((FUNC ARGLIST BODY...) ...) FORM...)"
>   (require 'cl)
>   (if (fboundp 'cl-letf)
>       `(cl-letf ,(mapcar (lambda (binding)
> 			   `((symbol-function ',(car binding))
> 			     (lambda ,@(cdr binding))))
> 			 bindings)
> 	 ,@body)
>     `(flet ,bindings ,@body)))
> (put 'mh-cl-flet 'lisp-indent-function 1)
> (put 'mh-cl-flet 'edebug-form-spec
>      '((&rest (sexp sexp &rest form)) &rest form))
> --8<---------------cut here---------------end--------------->8---
>
> I'm not the right person to install it since I'm not a mh-e user,
> sorry.
>
> Regards,





  reply	other threads:[~2016-01-14 17:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06  1:01 bug#22317: 25.0.50; mh-e: wrong usage of cl-flet Katsumi Yamaoka
2016-01-14 17:46 ` Glenn Morris [this message]
2016-01-14 18:42   ` Bill Wohler
2016-05-31  0:18   ` Bill Wohler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f737u0vytv.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=22317@debbugs.gnu.org \
    --cc=yamaoka@jpl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.