* setf buffer-file-name
@ 2008-04-07 5:34 Devon Sean McCullough
2008-04-07 19:10 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Devon Sean McCullough @ 2008-04-07 5:34 UTC (permalink / raw)
To: Dave Gillespie; +Cc: Emacs-Devel
Hi Dave,
Two questions and two patches.
(A) Should cl-macs.el patches go to you or
to <Emacs-Devel@gnu.org> or someplace like that?
(B) Should (with-current-buffer nil ...)
keep the same buffer current rather than error?
This would fix a bug in (setf (buffer-modified-p) x)
left broken below in case this makes it moot.
(1) Documented defsetf simple form third argument.
(2) Broken (setf (buffer-file-name buffer) filename)
fixed below. Perhaps the optional buffer arg
came after the old defsetf was written.
Will fix more in this same vein
as time permits.
Peace
--Devon
/~\
\ / Health Care
X not warfare
/ \
Dubya slime won the digital vote
Kerry slime won the popular vote
PS: Thanks for the software!
Index: lisp/emacs-lisp/cl-macs.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/cl-macs.el,v
retrieving revision 1.72
diff -u -r1.72 cl-macs.el
--- lisp/emacs-lisp/cl-macs.el 3 Apr 2008 13:42:25 -0000 1.72
+++ lisp/emacs-lisp/cl-macs.el 7 Apr 2008 04:56:12 -0000
@@ -1604,9 +1604,13 @@
This macro is an easy-to-use substitute for `define-setf-method' that works
well for simple place forms. In the simple `defsetf' form, `setf's of
the form (setf (NAME ARGS...) VAL) are transformed to function or macro
-calls of the form (FUNC ARGS... VAL). Example:
+calls of the form (FUNC ARGS... VAL). Examples:
(defsetf aref aset)
+ (defsetf file-modes set-file-modes t)
+
+Optional third arg omitted or nil assumes FUNC always returns VAL,
+non-nil wraps it in a (progn ... VAL) in case it might not.
Alternate form: (defsetf NAME ARGLIST (STORE) BODY...).
Here, the above `setf' call is expanded by binding the argument forms ARGS
@@ -1717,7 +1721,13 @@
(defsetf rest setcdr)
;;; Some more Emacs-related place types.
-(defsetf buffer-file-name set-visited-file-name t)
+(defsetf buffer-file-name (&optional buf) (filename)
+ (list 'progn
+ (list 'if buf
+ (list 'with-current-buffer buf
+ (list 'set-visited-file-name filename))
+ (list 'set-visited-file-name filename))
+ filename))
(defsetf buffer-modified-p (&optional buf) (flag)
(list 'with-current-buffer buf
(list 'set-buffer-modified-p flag)))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: setf buffer-file-name
2008-04-07 5:34 setf buffer-file-name Devon Sean McCullough
@ 2008-04-07 19:10 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2008-04-07 19:10 UTC (permalink / raw)
To: Devon Sean McCullough; +Cc: Dave Gillespie, Emacs-Devel
> (A) Should cl-macs.el patches go to you or
> to <Emacs-Devel@gnu.org> or someplace like that?
You can report any bug in the code of Emacs with M-x report-emacs-bug.
I do not know if Dave still worries about CL, but indeed if he does not
we should fix the cl*.el headers to say "Maintainer: FSF".
> (B) Should (with-current-buffer nil ...)
> keep the same buffer current rather than error?
I don't see a strong need to make it work as you suggest.
It's pretty easy to use (or <foo> (current-buffer)) for the few cases
where this might be useful.
> (1) Documented defsetf simple form third argument.
Thanks.
> ;;; Some more Emacs-related place types.
> -(defsetf buffer-file-name set-visited-file-name t)
> +(defsetf buffer-file-name (&optional buf) (filename)
> + (list 'progn
> + (list 'if buf
> + (list 'with-current-buffer buf
> + (list 'set-visited-file-name filename))
> + (list 'set-visited-file-name filename))
> + filename))
Actually, while your patch is correct, I wonder if using
set-visited-file-name is really a good idea here. Yes, it's probably
the cleanest way to set buffer-file-name in some cases, but it does
a lot more than just set buffer-file-name, so I'm not sure if it should
be hidden as a mere "setf".
I.e., I suggest to remove this defsetf altogether.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-07 19:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-07 5:34 setf buffer-file-name Devon Sean McCullough
2008-04-07 19:10 ` Stefan Monnier
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.