[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
setf buffer-file-name
From: |
Devon Sean McCullough |
Subject: |
setf buffer-file-name |
Date: |
Sun, 6 Apr 2008 22:34:29 -0700 (PDT) |
Hi Dave,
Two questions and two patches.
(A) Should cl-macs.el patches go to you or
to <address@hidden> 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)))
- setf buffer-file-name,
Devon Sean McCullough <=