* flet is obsolete, but...
@ 2012-10-10 12:39 Sebastien Vauban
2012-10-10 13:17 ` Jambunathan K
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Sebastien Vauban @ 2012-10-10 12:39 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hello,
`flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
But doing so in the following code:
--8<---------------cut here---------------start------------->8---
(defun my/revert-buffer ()
"Unconditionally revert current buffer."
(interactive)
(flet ((yes-or-no-p (msg) t))
(revert-buffer)))
--8<---------------cut here---------------end--------------->8---
does not lead to the right things:
- use cl-flet, and the code doesn't behave as it should (i.e., it does ask for
a confirmation, before reverting)
- use cl-letf, and you've got an error:
cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t
What should I do?
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-10 12:39 flet is obsolete, but Sebastien Vauban
@ 2012-10-10 13:17 ` Jambunathan K
2012-10-10 13:18 ` Jambunathan K
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Jambunathan K @ 2012-10-10 13:17 UTC (permalink / raw)
To: Help GNU Emacs
> Hello,
>
> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>
> But doing so in the following code:
>
>
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (flet ((yes-or-no-p (msg) t))
> (revert-buffer)))
>
>
> does not lead to the right things:
>
> - use cl-flet, and the code doesn't behave as it should (i.e., it does ask for
> a confirmation, before reverting)
>
> - use cl-letf, and you've got an error:
> cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t
>
> What should I do?
Use the NOCONFIRM of revert-buffer.
> Best regards,
> Seb
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-10 12:39 flet is obsolete, but Sebastien Vauban
2012-10-10 13:17 ` Jambunathan K
@ 2012-10-10 13:18 ` Jambunathan K
2012-10-10 14:31 ` Barry Margolin
[not found] ` <mailman.10697.1349875031.855.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 11+ messages in thread
From: Jambunathan K @ 2012-10-10 13:18 UTC (permalink / raw)
To: Help GNU Emacs
> Hello,
>
> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>
> But doing so in the following code:
>
>
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (flet ((yes-or-no-p (msg) t))
> (revert-buffer)))
>
>
> does not lead to the right things:
>
> - use cl-flet, and the code doesn't behave as it should (i.e., it does ask for
> a confirmation, before reverting)
>
> - use cl-letf, and you've got an error:
> cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t
>
> What should I do?
Use the NOCONFIRM argument of revert-buffer.
> Best regards,
> Seb
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-10 12:39 flet is obsolete, but Sebastien Vauban
2012-10-10 13:17 ` Jambunathan K
2012-10-10 13:18 ` Jambunathan K
@ 2012-10-10 14:31 ` Barry Margolin
2012-10-11 14:55 ` Sebastien Vauban
[not found] ` <mailman.10697.1349875031.855.help-gnu-emacs@gnu.org>
3 siblings, 1 reply; 11+ messages in thread
From: Barry Margolin @ 2012-10-10 14:31 UTC (permalink / raw)
To: help-gnu-emacs
In article <804nm2zekk.fsf@somewhere.org>,
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> wrote:
> Hello,
>
> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>
> But doing so in the following code:
>
> --8<---------------cut here---------------start------------->8---
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (flet ((yes-or-no-p (msg) t))
> (revert-buffer)))
> --8<---------------cut here---------------end--------------->8---
>
> does not lead to the right things:
>
> - use cl-flet, and the code doesn't behave as it should (i.e., it does ask for
> a confirmation, before reverting)'
cl-flet does lexical binding, not dynamic.
>
> - use cl-letf, and you've got an error:
> cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t
>
> What should I do?
Sounds like you didn't write your cl-letf correctly. Did you read its
documentation? It's not a drop-in replacement for flet, since it's more
general than this (it's used to temporarily assign to any place that can
be set with setf).
(letf (((symbol-function 'yes-or-no-p)
#'(lambda (msg) t)))
(revert-buffer))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
[not found] ` <mailman.10697.1349875031.855.help-gnu-emacs@gnu.org>
@ 2012-10-11 8:04 ` Sebastien Vauban
2012-10-11 8:10 ` Tassilo Horn
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Sebastien Vauban @ 2012-10-11 8:04 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hi Jambunathan,
Jambunathan K wrote:
>> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>>
>> But doing so in the following code:
>>
>> (defun my/revert-buffer ()
>> "Unconditionally revert current buffer."
>> (interactive)
>> (flet ((yes-or-no-p (msg) t))
>> (revert-buffer)))
>>
>> does not lead to the right things:
>> What should I do?
>
> Use the NOCONFIRM argument of revert-buffer.
I tried another way:
--8<---------------cut here---------------start------------->8---
(defun my/revert-buffer ()
"Unconditionally revert current buffer."
(interactive)
(let ((revert-without-query t))
(revert-buffer)))
--8<---------------cut here---------------end--------------->8---
but I don't understand why it does not work:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument listp t)
byte-code("\b\304\211\205\x1f\n@\305 \v\"\203
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-11 8:04 ` Sebastien Vauban
@ 2012-10-11 8:10 ` Tassilo Horn
2012-10-11 8:17 ` Jambunathan K
2012-10-11 13:48 ` Drew Adams
2 siblings, 0 replies; 11+ messages in thread
From: Tassilo Horn @ 2012-10-11 8:10 UTC (permalink / raw)
To: help-gnu-emacs
"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> writes:
>> Use the NOCONFIRM argument of revert-buffer.
>
> I tried another way:
What's wrong with NOCONFIRM?
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (let ((revert-without-query t))
> (revert-buffer)))
>
> but I don't understand why it does not work:
>
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (wrong-type-argument listp t)
> byte-code("\b\304\211\205\x1f\n@\305 \v\"\203
Because t is not a list. The docs clearly state that
`revert-without-query' has to be a list of regular expressions.
,----[ C-h v revert-without-query RET ]
| revert-without-query is a variable defined in `files.el'.
| Its value is nil
|
| Documentation:
| Specify which files should be reverted without query.
| The value is a list of regular expressions.
| If the file name matches one of these regular expressions,
| then `revert-buffer' reverts the file without querying
| if the file has changed on disk and you have not edited the buffer.
`----
Bye,
Tassilo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-11 8:04 ` Sebastien Vauban
2012-10-11 8:10 ` Tassilo Horn
@ 2012-10-11 8:17 ` Jambunathan K
2012-10-11 13:48 ` Drew Adams
2 siblings, 0 replies; 11+ messages in thread
From: Jambunathan K @ 2012-10-11 8:17 UTC (permalink / raw)
To: Help GNU Emacs
"Sebastien Vauban"
<wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
> Hi Jambunathan,
>
> Jambunathan K wrote:
>>> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>>>
>>> But doing so in the following code:
>>>
>>> (defun my/revert-buffer ()
>>> "Unconditionally revert current buffer."
>>> (interactive)
>>> (flet ((yes-or-no-p (msg) t))
>>> (revert-buffer)))
>>>
>>> does not lead to the right things:
>>> What should I do?
>>
>> Use the NOCONFIRM argument of revert-buffer.
>
> I tried another way:
>
>
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (let ((revert-without-query t))
> (revert-buffer)))
>
>
> but I don't understand why it does not work:
>
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (wrong-type-argument listp t)
> byte-code("\b\304\211\205\x1f\n@\305 \v\"\203
>
listp in above Lisp error gives a clue that a list is expected.
A describe variable confirms that it is indeed a list regexes. Regex is
a Emacs regex and NOT a shell-regex.
,----[ C-h v revert-without-query RET ]
| revert-without-query is a variable defined in `files.el'.
| Its value is nil
|
| Documentation:
| Specify which files should be reverted without query.
| The value is a list of regular expressions.
| If the file name matches one of these regular expressions,
| then `revert-buffer' reverts the file without querying
| if the file has changed on disk and you have not edited the buffer.
|
| You can customize this variable.
|
| [back]
`----
--
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: flet is obsolete, but...
2012-10-11 8:04 ` Sebastien Vauban
2012-10-11 8:10 ` Tassilo Horn
2012-10-11 8:17 ` Jambunathan K
@ 2012-10-11 13:48 ` Drew Adams
2012-10-11 14:33 ` Ludwig, Mark
2 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2012-10-11 13:48 UTC (permalink / raw)
To: 'Sebastien Vauban', help-gnu-emacs
> (defun my/revert-buffer ()
> "Unconditionally revert current buffer."
> (interactive)
> (let ((revert-without-query t)) (revert-buffer)))
>
> but I don't understand why it does not work:
Others have explained why it does not work.
Here's another way:
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive) (revert-buffer t t))
(I bind it to `f5', in keeping with the MS Windows use of that key.)
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: flet is obsolete, but...
2012-10-11 13:48 ` Drew Adams
@ 2012-10-11 14:33 ` Ludwig, Mark
2012-10-11 15:18 ` `f5' for refreshing/reverting without confirmation [was: flet is obsolete, but...] Drew Adams
0 siblings, 1 reply; 11+ messages in thread
From: Ludwig, Mark @ 2012-10-11 14:33 UTC (permalink / raw)
To: Drew Adams, 'Sebastien Vauban', help-gnu-emacs@gnu.org
> -----Original Message-----
> From: Drew Adams
> Sent: Thursday, October 11, 2012 8:49 AM
> To: 'Sebastien Vauban'; help-gnu-emacs@gnu.org
> Subject: RE: flet is obsolete, but...
>
> (I bind [revert-buffer-no-confirm] to `f5', in keeping with the MS Windows use of that key.)
That's the best idea I've seen in a /long/ time. Why didn't /I/ think of that?!
Thanks!
Mark
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: flet is obsolete, but...
2012-10-10 14:31 ` Barry Margolin
@ 2012-10-11 14:55 ` Sebastien Vauban
0 siblings, 0 replies; 11+ messages in thread
From: Sebastien Vauban @ 2012-10-11 14:55 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hello all,
Barry Margolin wrote:
> In article <804nm2zekk.fsf-oHC15RC7JGTNLxjTenLetw@public.gmane.org>,
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>
>> Hello,
>>
>> `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
>>
>> But doing so in the following code:
>>
>> --8<---------------cut here---------------start------------->8---
>> (defun my/revert-buffer ()
>> "Unconditionally revert current buffer."
>> (interactive)
>> (flet ((yes-or-no-p (msg) t))
>> (revert-buffer)))
>> --8<---------------cut here---------------end--------------->8---
>>
>> does not lead to the right things:
>>
>> - use cl-flet, and the code doesn't behave as it should (i.e., it does ask for
>> a confirmation, before reverting)'
>
> cl-flet does lexical binding, not dynamic.
>
>>
>> - use cl-letf, and you've got an error:
>> cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t
>>
>> What should I do?
>
> Sounds like you didn't write your cl-letf correctly. Did you read its
> documentation? It's not a drop-in replacement for flet, since it's more
> general than this (it's used to temporarily assign to any place that can
> be set with setf).
>
> (letf (((symbol-function 'yes-or-no-p)
> #'(lambda (msg) t)))
> (revert-buffer))
Thanks for your answers. It helped a lot, even if the above is still a bit
cryptic to me.
And, yes, I thought that the replacement was purely a syntaxical exchange of
words...
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 11+ messages in thread
* `f5' for refreshing/reverting without confirmation [was: flet is obsolete, but...]
2012-10-11 14:33 ` Ludwig, Mark
@ 2012-10-11 15:18 ` Drew Adams
0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2012-10-11 15:18 UTC (permalink / raw)
To: 'Ludwig, Mark', 'Sebastien Vauban',
help-gnu-emacs
> > (I bind [revert-buffer-no-confirm] to `f5', in keeping with
> > the MS Windows use of that key.)
>
> That's the best idea I've seen in a /long/ time.
> Why didn't /I/ think of that?!
You're welcome. Sometimes a trivial change can make a difference.
I must say that "wasting" an easy, repeatable key such as `f5' on this (as
opposed to binding it to a command that could take advantage of holding down the
key to repeat) goes against my general guidelines.
But in this case I made an exception because I already have the habit of using
it in Windows apps, so it is handy (for me).
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-10-11 15:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-10 12:39 flet is obsolete, but Sebastien Vauban
2012-10-10 13:17 ` Jambunathan K
2012-10-10 13:18 ` Jambunathan K
2012-10-10 14:31 ` Barry Margolin
2012-10-11 14:55 ` Sebastien Vauban
[not found] ` <mailman.10697.1349875031.855.help-gnu-emacs@gnu.org>
2012-10-11 8:04 ` Sebastien Vauban
2012-10-11 8:10 ` Tassilo Horn
2012-10-11 8:17 ` Jambunathan K
2012-10-11 13:48 ` Drew Adams
2012-10-11 14:33 ` Ludwig, Mark
2012-10-11 15:18 ` `f5' for refreshing/reverting without confirmation [was: flet is obsolete, but...] Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).