summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/gv.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/gv.el')
-rw-r--r--lisp/emacs-lisp/gv.el44
1 files changed, 29 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index b7b54b2a6b1..8e69c8d0447 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -182,7 +182,7 @@ If CURRENT-NAME is a string, that is the `use instead' message.
WHEN should be a string indicating when the variable was first
made obsolete, for example a date or a release number."
(put obsolete-name 'byte-obsolete-generalized-variable
- (purecopy (list current-name when)))
+ (list current-name when))
obsolete-name)
;; Additions for `declare'. We specify the values as named aliases so
@@ -294,7 +294,7 @@ The return value is the last VAL in the list.
\(fn PLACE VAL PLACE VAL ...)"
(declare (debug (&rest [gv-place form])))
- (if (/= (logand (length args) 1) 0)
+ (if (oddp (length args))
(signal 'wrong-number-of-arguments (list 'setf (length args))))
(if (and args (null (cddr args)))
(let ((place (pop args))
@@ -315,17 +315,29 @@ The return value is the last VAL in the list.
;; `(if (member ,v ,getter) nil
;; ,(funcall setter `(cons ,v ,getter))))))
-;; (defmacro gv-inc! (place &optional val)
-;; "Increment PLACE by VAL (default to 1)."
-;; (declare (debug (gv-place &optional form)))
-;; (gv-letplace (getter setter) place
-;; (funcall setter `(+ ,getter ,(or val 1)))))
+;;;###autoload
+(defmacro incf (place &optional delta)
+ "Increment PLACE by DELTA (default to 1).
-;; (defmacro gv-dec! (place &optional val)
-;; "Decrement PLACE by VAL (default to 1)."
-;; (declare (debug (gv-place &optional form)))
-;; (gv-letplace (getter setter) place
-;; (funcall setter `(- ,getter ,(or val 1)))))
+The DELTA is first added to PLACE, and then stored in PLACE.
+Return the incremented value of PLACE.
+
+See also `decf'."
+ (declare (debug (gv-place &optional form)))
+ (gv-letplace (getter setter) place
+ (funcall setter `(+ ,getter ,(or delta 1)))))
+
+;;;###autoload
+(defmacro decf (place &optional delta)
+ "Decrement PLACE by DELTA (default to 1).
+
+The DELTA is first subtracted from PLACE, and then stored in PLACE.
+Return the decremented value of PLACE.
+
+See also `incf'."
+ (declare (debug (gv-place &optional form)))
+ (gv-letplace (getter setter) place
+ (funcall setter `(- ,getter ,(or delta 1)))))
;; For Edebug, the idea is to let Edebug instrument gv-places just like it does
;; for normal expressions, and then give it a gv-expander to DTRT.
@@ -388,13 +400,15 @@ The return value is the last VAL in the list.
(gv-define-simple-setter match-data set-match-data 'fix)
(gv-define-simple-setter overlay-get overlay-put)
(gv-define-setter overlay-start (store ov)
- `(progn (move-overlay ,ov ,store (overlay-end ,ov)) ,store))
+ (macroexp-let2 nil store store
+ `(progn (move-overlay ,ov ,store (overlay-end ,ov)) ,store)))
(gv-define-setter overlay-end (store ov)
- `(progn (move-overlay ,ov (overlay-start ,ov) ,store) ,store))
+ (macroexp-let2 nil store store
+ `(progn (move-overlay ,ov (overlay-start ,ov) ,store) ,store)))
(gv-define-simple-setter process-buffer set-process-buffer)
(gv-define-simple-setter process-filter set-process-filter)
(gv-define-simple-setter process-sentinel set-process-sentinel)
-(gv-define-simple-setter process-get process-put)
+(gv-define-simple-setter process-get process-put 'fix)
(gv-define-simple-setter window-parameter set-window-parameter)
(gv-define-setter window-buffer (v &optional w)
(macroexp-let2 nil v v