diff options
| author | Stefan Monnier | 2014-10-01 13:23:42 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-10-01 13:23:42 -0400 |
| commit | a57fa9642d4953dd6b249f563776e8e9ed60ced5 (patch) | |
| tree | e0efbcabdb8f42dd534423686cd97f34e3641647 | |
| parent | 34912c0a2be7a48969652b1556d2998240c59a22 (diff) | |
| download | emacs-a57fa9642d4953dd6b249f563776e8e9ed60ced5.tar.gz emacs-a57fa9642d4953dd6b249f563776e8e9ed60ced5.zip | |
* lisp/subr.el (alist-get): New accessor.
* lisp/emacs-lisp/gv.el (alist-get): Provide expander.
* lisp/winner.el (winner-remember):
* lisp/tempo.el (tempo-use-tag-list):
* lisp/progmodes/gud.el (minor-mode-map-alist):
* lisp/international/mule-cmds.el (define-char-code-property):
* lisp/frameset.el (frameset-filter-params):
* lisp/files.el (dir-locals-set-class-variables):
* lisp/register.el (get-register, set-register):
* lisp/calc/calc-yank.el (calc-set-register): Use it.
* lisp/ps-print.el (ps-get, ps-put, ps-del): Mark as obsolete.
* lisp/tooltip.el (tooltip-set-param): Mark as obsolete.
(tooltip-show): Use alist-get instead.
* lisp/ses.el (ses--alist-get): Remove. Use alist-get instead.
* admin/unidata/unidata-gen.el (unidata-gen-table-word-list): Use alist-get
and cl-incf.
| -rw-r--r-- | admin/ChangeLog | 5 | ||||
| -rw-r--r-- | admin/unidata/unidata-gen.el | 8 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/calc/calc-prog.el | 3 | ||||
| -rw-r--r-- | lisp/calc/calc-yank.el | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/gv.el | 51 | ||||
| -rw-r--r-- | lisp/files.el | 5 | ||||
| -rw-r--r-- | lisp/frameset.el | 5 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/gud.el | 5 | ||||
| -rw-r--r-- | lisp/ps-print.el | 3 | ||||
| -rw-r--r-- | lisp/register.el | 10 | ||||
| -rw-r--r-- | lisp/ses.el | 41 | ||||
| -rw-r--r-- | lisp/subr.el | 9 | ||||
| -rw-r--r-- | lisp/tempo.el | 6 | ||||
| -rw-r--r-- | lisp/tooltip.el | 14 | ||||
| -rw-r--r-- | lisp/winner.el | 5 |
18 files changed, 104 insertions, 100 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog index 4ebf97d3163..cd5f08989fc 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-10-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * unidata/unidata-gen.el (unidata-gen-table-word-list): Use alist-get | ||
| 4 | and cl-incf. | ||
| 5 | |||
| 1 | 2014-09-08 Eli Zaretskii <eliz@gnu.org> | 6 | 2014-09-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * unidata/unidata-gen.el (unidata-check): Bring this function up | 8 | * unidata/unidata-gen.el (unidata-check): Bring this function up |
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el index fb9b6dccc72..ec4f9d154d2 100644 --- a/admin/unidata/unidata-gen.el +++ b/admin/unidata/unidata-gen.el | |||
| @@ -88,6 +88,8 @@ | |||
| 88 | ;; CHAR-or-RANGE: a character code or a cons of character codes | 88 | ;; CHAR-or-RANGE: a character code or a cons of character codes |
| 89 | ;; PROPn: string representing the nth property value | 89 | ;; PROPn: string representing the nth property value |
| 90 | 90 | ||
| 91 | (eval-when-compile (require 'cl-lib)) | ||
| 92 | |||
| 91 | (defvar unidata-list nil) | 93 | (defvar unidata-list nil) |
| 92 | 94 | ||
| 93 | ;; Name of the directory containing files of Unicode Character Database. | 95 | ;; Name of the directory containing files of Unicode Character Database. |
| @@ -923,11 +925,7 @@ is the character itself."))) | |||
| 923 | (dotimes (i (length vec)) | 925 | (dotimes (i (length vec)) |
| 924 | (dolist (elt (aref vec i)) | 926 | (dolist (elt (aref vec i)) |
| 925 | (if (symbolp elt) | 927 | (if (symbolp elt) |
| 926 | (let ((slot (assq elt word-list))) | 928 | (cl-incf (alist-get elt (cdr word-list) 0))))) |
| 927 | (if slot | ||
| 928 | (setcdr slot (1+ (cdr slot))) | ||
| 929 | (setcdr word-list | ||
| 930 | (cons (cons elt 1) (cdr word-list)))))))) | ||
| 931 | (set-char-table-range table (cons start limit) vec)))))) | 929 | (set-char-table-range table (cons start limit) vec)))))) |
| 932 | (setq word-list (sort (cdr word-list) | 930 | (setq word-list (sort (cdr word-list) |
| 933 | #'(lambda (x y) (> (cdr x) (cdr y))))) | 931 | #'(lambda (x y) (> (cdr x) (cdr y))))) |
| @@ -245,6 +245,8 @@ Emacs-21. | |||
| 245 | *** call-process-shell-command and process-file-shell-command | 245 | *** call-process-shell-command and process-file-shell-command |
| 246 | don't take "&rest args" any more. | 246 | don't take "&rest args" any more. |
| 247 | 247 | ||
| 248 | ** New function `alist-get', which is also a valid place (aka lvalue). | ||
| 249 | |||
| 248 | ** New function `funcall-interactively', which works like `funcall' | 250 | ** New function `funcall-interactively', which works like `funcall' |
| 249 | but makes `called-interactively-p' treat the function as (you guessed it) | 251 | but makes `called-interactively-p' treat the function as (you guessed it) |
| 250 | called interactively. | 252 | called interactively. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b1e510b6f7d..ea8587e40a4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2014-10-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * subr.el (alist-get): New accessor. | ||
| 4 | * emacs-lisp/gv.el (alist-get): Provide expander. | ||
| 5 | * winner.el (winner-remember): | ||
| 6 | * tempo.el (tempo-use-tag-list): | ||
| 7 | * progmodes/gud.el (minor-mode-map-alist): | ||
| 8 | * international/mule-cmds.el (define-char-code-property): | ||
| 9 | * frameset.el (frameset-filter-params): | ||
| 10 | * files.el (dir-locals-set-class-variables): | ||
| 11 | * register.el (get-register, set-register): | ||
| 12 | * calc/calc-yank.el (calc-set-register): Use it. | ||
| 13 | * ps-print.el (ps-get, ps-put, ps-del): Mark as obsolete. | ||
| 14 | * tooltip.el (tooltip-set-param): Mark as obsolete. | ||
| 15 | (tooltip-show): Use alist-get instead. | ||
| 16 | * ses.el (ses--alist-get): Remove. Use alist-get instead. | ||
| 17 | |||
| 1 | 2014-10-01 Ulf Jasper <ulf.jasper@web.de> | 18 | 2014-10-01 Ulf Jasper <ulf.jasper@web.de> |
| 2 | 19 | ||
| 3 | * net/newst-backend.el: Remove Time-stamp. Rename variable | 20 | * net/newst-backend.el: Remove Time-stamp. Rename variable |
| @@ -5,8 +22,8 @@ | |||
| 5 | make it customizable. | 22 | make it customizable. |
| 6 | (newsticker--sentinel-work): Move xml-workarounds to function | 23 | (newsticker--sentinel-work): Move xml-workarounds to function |
| 7 | `newsticker--do-xml-workarounds', call unless libxml-parser is | 24 | `newsticker--do-xml-workarounds', call unless libxml-parser is |
| 8 | used. Allow single quote in regexp for encoding. Use | 25 | used. Allow single quote in regexp for encoding. |
| 9 | libxml-parser if available, else fall back to `xml-parse-region'. | 26 | Use libxml-parser if available, else fall back to `xml-parse-region'. |
| 10 | Take care of possibly missing namespace prefixes (like "RDF" | 27 | Take care of possibly missing namespace prefixes (like "RDF" |
| 11 | instead of "rdf:RDF") when checking xml nodes and attributes (as | 28 | instead of "rdf:RDF") when checking xml nodes and attributes (as |
| 12 | libxml correctly removes the prefixes). Always use Atom 1.0 as | 29 | libxml correctly removes the prefixes). Always use Atom 1.0 as |
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el index 30a06a2aa00..156bf4cd0db 100644 --- a/lisp/calc/calc-prog.el +++ b/lisp/calc/calc-prog.el | |||
| @@ -139,6 +139,7 @@ | |||
| 139 | "calc-")))) | 139 | "calc-")))) |
| 140 | (let* ((kmap (calc-user-key-map)) | 140 | (let* ((kmap (calc-user-key-map)) |
| 141 | (old (assq key kmap))) | 141 | (old (assq key kmap))) |
| 142 | ;; FIXME: Why not (define-key kmap (vector key) func)? | ||
| 142 | (if old | 143 | (if old |
| 143 | (setcdr old func) | 144 | (setcdr old func) |
| 144 | (setcdr kmap (cons (cons key func) (cdr kmap)))))))) | 145 | (setcdr kmap (cons (cons key func) (cdr kmap)))))))) |
| @@ -322,6 +323,7 @@ | |||
| 322 | (if key | 323 | (if key |
| 323 | (let* ((kmap (calc-user-key-map)) | 324 | (let* ((kmap (calc-user-key-map)) |
| 324 | (old (assq key kmap))) | 325 | (old (assq key kmap))) |
| 326 | ;; FIXME: Why not (define-key kmap (vector key) cmd)? | ||
| 325 | (if old | 327 | (if old |
| 326 | (setcdr old cmd) | 328 | (setcdr old cmd) |
| 327 | (setcdr kmap (cons (cons key cmd) (cdr kmap))))))) | 329 | (setcdr kmap (cons (cons key cmd) (cdr kmap))))))) |
| @@ -467,6 +469,7 @@ | |||
| 467 | (format "z%c" key))))) | 469 | (format "z%c" key))))) |
| 468 | (let* ((kmap (calc-user-key-map)) | 470 | (let* ((kmap (calc-user-key-map)) |
| 469 | (old (assq key kmap))) | 471 | (old (assq key kmap))) |
| 472 | ;; FIXME: Why not (define-key kmap (vector key) func)? | ||
| 470 | (if old | 473 | (if old |
| 471 | (setcdr old cmd) | 474 | (setcdr old cmd) |
| 472 | (setcdr kmap (cons (cons key cmd) (cdr kmap)))))))) | 475 | (setcdr kmap (cons (cons key cmd) (cdr kmap)))))))) |
diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index 8d182372cfb..9781d4174f5 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el | |||
| @@ -143,10 +143,7 @@ TEXT and CALCVAL are the TEXT and internal structure of stack entries.") | |||
| 143 | "Set the contents of the Calc register REGISTER to (TEXT . CALCVAL), | 143 | "Set the contents of the Calc register REGISTER to (TEXT . CALCVAL), |
| 144 | as well as set the contents of the Emacs register REGISTER to TEXT." | 144 | as well as set the contents of the Emacs register REGISTER to TEXT." |
| 145 | (set-register register text) | 145 | (set-register register text) |
| 146 | (let ((aelt (assq register calc-register-alist))) | 146 | (setf (alist-get register calc-register-alist) (cons text calcval))) |
| 147 | (if aelt | ||
| 148 | (setcdr aelt (cons text calcval)) | ||
| 149 | (push (cons register (cons text calcval)) calc-register-alist)))) | ||
| 150 | 147 | ||
| 151 | (defun calc-get-register (reg) | 148 | (defun calc-get-register (reg) |
| 152 | "Return the CALCVAL portion of the contents of the Calc register REG, | 149 | "Return the CALCVAL portion of the contents of the Calc register REG, |
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 692b76e8a36..229ad275bf5 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el | |||
| @@ -357,6 +357,34 @@ The return value is the last VAL in the list. | |||
| 357 | (macroexp-let2 nil v val | 357 | (macroexp-let2 nil v val |
| 358 | `(with-current-buffer ,buf (set (make-local-variable ,var) ,v)))) | 358 | `(with-current-buffer ,buf (set (make-local-variable ,var) ,v)))) |
| 359 | 359 | ||
| 360 | (gv-define-expander alist-get | ||
| 361 | (lambda (do key alist &optional default remove) | ||
| 362 | (macroexp-let2 macroexp-copyable-p k key | ||
| 363 | (gv-letplace (getter setter) alist | ||
| 364 | (macroexp-let2 nil p `(assq ,k ,getter) | ||
| 365 | (funcall do (if (null default) `(cdr ,p) | ||
| 366 | `(if ,p (cdr ,p) ,default)) | ||
| 367 | (lambda (v) | ||
| 368 | (macroexp-let2 nil v v | ||
| 369 | (let ((set-exp | ||
| 370 | `(if ,p (setcdr ,p ,v) | ||
| 371 | ,(funcall setter | ||
| 372 | `(cons (setq ,p (cons ,k ,v)) | ||
| 373 | ,getter))))) | ||
| 374 | (cond | ||
| 375 | ((null remove) set-exp) | ||
| 376 | ((or (eql v default) | ||
| 377 | (and (eq (car-safe v) 'quote) | ||
| 378 | (eq (car-safe default) 'quote) | ||
| 379 | (eql (cadr v) (cadr default)))) | ||
| 380 | `(if ,p ,(funcall setter `(delq ,p ,getter)))) | ||
| 381 | (t | ||
| 382 | `(cond | ||
| 383 | ((not (eql ,default ,v)) ,set-exp) | ||
| 384 | (,p ,(funcall setter | ||
| 385 | `(delq ,p ,getter))))))))))))))) | ||
| 386 | |||
| 387 | |||
| 360 | ;;; Some occasionally handy extensions. | 388 | ;;; Some occasionally handy extensions. |
| 361 | 389 | ||
| 362 | ;; While several of the "places" below are not terribly useful for direct use, | 390 | ;; While several of the "places" below are not terribly useful for direct use, |
| @@ -479,22 +507,13 @@ REF must have been previously obtained with `gv-ref'." | |||
| 479 | ;; … => (load "gv.el") => (macroexpand-all (defsubst gv-deref …)) => (macroexpand (defun …)) => (load "gv.el") | 507 | ;; … => (load "gv.el") => (macroexpand-all (defsubst gv-deref …)) => (macroexpand (defun …)) => (load "gv.el") |
| 480 | (gv-define-setter gv-deref (v ref) `(funcall (cdr ,ref) ,v)) | 508 | (gv-define-setter gv-deref (v ref) `(funcall (cdr ,ref) ,v)) |
| 481 | 509 | ||
| 482 | ;;; Vaguely related definitions that should be moved elsewhere. | 510 | ;; (defmacro gv-letref (vars place &rest body) |
| 483 | 511 | ;; (declare (indent 2) (debug (sexp form &rest body))) | |
| 484 | ;; (defun alist-get (key alist) | 512 | ;; (require 'cl-lib) ;Can't require cl-lib at top-level for bootstrap reasons! |
| 485 | ;; "Get the value associated to KEY in ALIST." | 513 | ;; (gv-letplace (getter setter) place |
| 486 | ;; (declare | 514 | ;; `(cl-macrolet ((,(nth 0 vars) () ',getter) |
| 487 | ;; (gv-expander | 515 | ;; (,(nth 1 vars) (v) (funcall ',setter v))) |
| 488 | ;; (lambda (do) | 516 | ;; ,@body))) |
| 489 | ;; (macroexp-let2 macroexp-copyable-p k key | ||
| 490 | ;; (gv-letplace (getter setter) alist | ||
| 491 | ;; (macroexp-let2 nil p `(assoc ,k ,getter) | ||
| 492 | ;; (funcall do `(cdr ,p) | ||
| 493 | ;; (lambda (v) | ||
| 494 | ;; `(if ,p (setcdr ,p ,v) | ||
| 495 | ;; ,(funcall setter | ||
| 496 | ;; `(cons (cons ,k ,v) ,getter))))))))))) | ||
| 497 | ;; (cdr (assoc key alist))) | ||
| 498 | 517 | ||
| 499 | (provide 'gv) | 518 | (provide 'gv) |
| 500 | ;;; gv.el ends here | 519 | ;;; gv.el ends here |
diff --git a/lisp/files.el b/lisp/files.el index 5d1276f261e..f360c1342d6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3649,10 +3649,7 @@ VARIABLES list of the class. The list is processed in order. | |||
| 3649 | * If the element is of the form (DIRECTORY . LIST), and DIRECTORY | 3649 | * If the element is of the form (DIRECTORY . LIST), and DIRECTORY |
| 3650 | is an initial substring of the file's directory, then LIST is | 3650 | is an initial substring of the file's directory, then LIST is |
| 3651 | applied by recursively following these rules." | 3651 | applied by recursively following these rules." |
| 3652 | (let ((elt (assq class dir-locals-class-alist))) | 3652 | (setf (alist-get class dir-locals-class-alist) variables)) |
| 3653 | (if elt | ||
| 3654 | (setcdr elt variables) | ||
| 3655 | (push (cons class variables) dir-locals-class-alist)))) | ||
| 3656 | 3653 | ||
| 3657 | (defconst dir-locals-file ".dir-locals.el" | 3654 | (defconst dir-locals-file ".dir-locals.el" |
| 3658 | "File that contains directory-local variables. | 3655 | "File that contains directory-local variables. |
diff --git a/lisp/frameset.el b/lisp/frameset.el index b943d47e7bf..f8436259df0 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el | |||
| @@ -664,10 +664,7 @@ nil while the filtering is done to restore it." | |||
| 664 | ;; Set the display parameter after filtering, so that filter functions | 664 | ;; Set the display parameter after filtering, so that filter functions |
| 665 | ;; have access to its original value. | 665 | ;; have access to its original value. |
| 666 | (when frameset--target-display | 666 | (when frameset--target-display |
| 667 | (let ((display (assq 'display filtered))) | 667 | (setf (alist-get 'display filtered) (cdr frameset--target-display))) |
| 668 | (if display | ||
| 669 | (setcdr display (cdr frameset--target-display)) | ||
| 670 | (push frameset--target-display filtered)))) | ||
| 671 | filtered)) | 668 | filtered)) |
| 672 | 669 | ||
| 673 | 670 | ||
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index f6c0719e4c4..61ecc8b702a 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -2776,11 +2776,7 @@ See also the documentation of `get-char-code-property' and | |||
| 2776 | (or (stringp table) | 2776 | (or (stringp table) |
| 2777 | (error "Not a char-table nor a file name: %s" table))) | 2777 | (error "Not a char-table nor a file name: %s" table))) |
| 2778 | (if (stringp table) (setq table (purecopy table))) | 2778 | (if (stringp table) (setq table (purecopy table))) |
| 2779 | (let ((slot (assq name char-code-property-alist))) | 2779 | (setf (alist-get name char-code-property-alist) table) |
| 2780 | (if slot | ||
| 2781 | (setcdr slot table) | ||
| 2782 | (setq char-code-property-alist | ||
| 2783 | (cons (cons name table) char-code-property-alist)))) | ||
| 2784 | (put name 'char-code-property-documentation (purecopy docstring))) | 2780 | (put name 'char-code-property-documentation (purecopy docstring))) |
| 2785 | 2781 | ||
| 2786 | (defvar char-code-property-table | 2782 | (defvar char-code-property-table |
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index a2e015fd287..24d5469adc3 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el | |||
| @@ -256,9 +256,8 @@ Used to gray out relevant toolbar icons.") | |||
| 256 | ([menu-bar file] . undefined)))) | 256 | ([menu-bar file] . undefined)))) |
| 257 | "Map used in visited files.") | 257 | "Map used in visited files.") |
| 258 | 258 | ||
| 259 | (let ((m (assq 'gud-minor-mode minor-mode-map-alist))) | 259 | (setf (alist-get 'gud-minor-mode minor-mode-map-alist) |
| 260 | (if m (setcdr m gud-minor-mode-map) | 260 | gud-minor-mode-map) |
| 261 | (push (cons 'gud-minor-mode gud-minor-mode-map) minor-mode-map-alist))) | ||
| 262 | 261 | ||
| 263 | (defvar gud-mode-map | 262 | (defvar gud-mode-map |
| 264 | ;; Will inherit from comint-mode via define-derived-mode. | 263 | ;; Will inherit from comint-mode via define-derived-mode. |
diff --git a/lisp/ps-print.el b/lisp/ps-print.el index 83f2cde4010..28682f52b0e 100644 --- a/lisp/ps-print.el +++ b/lisp/ps-print.el | |||
| @@ -3822,6 +3822,7 @@ If `ps-prefix-quote' is nil, it's set to t after generating string." | |||
| 3822 | 3822 | ||
| 3823 | (defun ps-get (alist-sym key) | 3823 | (defun ps-get (alist-sym key) |
| 3824 | "Return element from association list ALIST-SYM which car is `eq' to KEY." | 3824 | "Return element from association list ALIST-SYM which car is `eq' to KEY." |
| 3825 | (declare (obsolete alist-get "25.1")) | ||
| 3825 | (assq key (symbol-value alist-sym))) | 3826 | (assq key (symbol-value alist-sym))) |
| 3826 | 3827 | ||
| 3827 | 3828 | ||
| @@ -3829,6 +3830,7 @@ If `ps-prefix-quote' is nil, it's set to t after generating string." | |||
| 3829 | "Store element (KEY . VALUE) into association list ALIST-SYM. | 3830 | "Store element (KEY . VALUE) into association list ALIST-SYM. |
| 3830 | If KEY already exists in ALIST-SYM, modify cdr to VALUE. | 3831 | If KEY already exists in ALIST-SYM, modify cdr to VALUE. |
| 3831 | It can be retrieved with `(ps-get ALIST-SYM KEY)'." | 3832 | It can be retrieved with `(ps-get ALIST-SYM KEY)'." |
| 3833 | (declare (obsolete "use (setf (alist-get ..) ..) instead" "25.1")) | ||
| 3832 | (let ((elt: (assq key (symbol-value alist-sym)))) ; to avoid name conflict | 3834 | (let ((elt: (assq key (symbol-value alist-sym)))) ; to avoid name conflict |
| 3833 | (if elt: | 3835 | (if elt: |
| 3834 | (setcdr elt: value) | 3836 | (setcdr elt: value) |
| @@ -3839,6 +3841,7 @@ It can be retrieved with `(ps-get ALIST-SYM KEY)'." | |||
| 3839 | 3841 | ||
| 3840 | (defun ps-del (alist-sym key) | 3842 | (defun ps-del (alist-sym key) |
| 3841 | "Delete by side effect element KEY from association list ALIST-SYM." | 3843 | "Delete by side effect element KEY from association list ALIST-SYM." |
| 3844 | (declare (obsolete "use (setf (alist-get k alist nil t) nil) instead" "25.1")) | ||
| 3842 | (let ((a:list: (symbol-value alist-sym)) ; to avoid name conflict | 3845 | (let ((a:list: (symbol-value alist-sym)) ; to avoid name conflict |
| 3843 | old) | 3846 | old) |
| 3844 | (while a:list: | 3847 | (while a:list: |
diff --git a/lisp/register.el b/lisp/register.el index ffa3c954ed2..24146065384 100644 --- a/lisp/register.el +++ b/lisp/register.el | |||
| @@ -33,6 +33,8 @@ | |||
| 33 | 33 | ||
| 34 | ;;; Code: | 34 | ;;; Code: |
| 35 | 35 | ||
| 36 | ;; FIXME: Clean up namespace usage! | ||
| 37 | |||
| 36 | (cl-defstruct | 38 | (cl-defstruct |
| 37 | (registerv (:constructor nil) | 39 | (registerv (:constructor nil) |
| 38 | (:constructor registerv--make (&optional data print-func | 40 | (:constructor registerv--make (&optional data print-func |
| @@ -98,16 +100,12 @@ If nil, do not show register previews, unless `help-char' (or a member of | |||
| 98 | 100 | ||
| 99 | (defun get-register (register) | 101 | (defun get-register (register) |
| 100 | "Return contents of Emacs register named REGISTER, or nil if none." | 102 | "Return contents of Emacs register named REGISTER, or nil if none." |
| 101 | (cdr (assq register register-alist))) | 103 | (alist-get register register-alist)) |
| 102 | 104 | ||
| 103 | (defun set-register (register value) | 105 | (defun set-register (register value) |
| 104 | "Set contents of Emacs register named REGISTER to VALUE. Returns VALUE. | 106 | "Set contents of Emacs register named REGISTER to VALUE. Returns VALUE. |
| 105 | See the documentation of the variable `register-alist' for possible VALUEs." | 107 | See the documentation of the variable `register-alist' for possible VALUEs." |
| 106 | (let ((aelt (assq register register-alist))) | 108 | (setf (alist-get register register-alist) value)) |
| 107 | (if aelt | ||
| 108 | (setcdr aelt value) | ||
| 109 | (push (cons register value) register-alist)) | ||
| 110 | value)) | ||
| 111 | 109 | ||
| 112 | (defun register-describe-oneline (c) | 110 | (defun register-describe-oneline (c) |
| 113 | "One-line description of register C." | 111 | "One-line description of register C." |
diff --git a/lisp/ses.el b/lisp/ses.el index ffd844d06bf..541c1e19769 100644 --- a/lisp/ses.el +++ b/lisp/ses.el | |||
| @@ -426,33 +426,6 @@ functions refer to its value." | |||
| 426 | (ses-get-cell (car rowcol) (cdr rowcol))))))) | 426 | (ses-get-cell (car rowcol) (cdr rowcol))))))) |
| 427 | 427 | ||
| 428 | 428 | ||
| 429 | (defun ses--alist-get (key alist &optional remove) | ||
| 430 | "Get the value associated to KEY in ALIST." | ||
| 431 | (declare | ||
| 432 | (gv-expander | ||
| 433 | (lambda (do) | ||
| 434 | (macroexp-let2 macroexp-copyable-p k key | ||
| 435 | (gv-letplace (getter setter) alist | ||
| 436 | (macroexp-let2 nil p `(assq ,k ,getter) | ||
| 437 | (funcall do `(cdr ,p) | ||
| 438 | (lambda (v) | ||
| 439 | (let ((set-exp | ||
| 440 | `(if ,p (setcdr ,p ,v) | ||
| 441 | ,(funcall setter | ||
| 442 | `(cons (setq ,p (cons ,k ,v)) | ||
| 443 | ,getter))))) | ||
| 444 | (cond | ||
| 445 | ((null remove) set-exp) | ||
| 446 | ((null v) | ||
| 447 | `(if ,p ,(funcall setter `(delq ,p ,getter)))) | ||
| 448 | (t | ||
| 449 | `(cond | ||
| 450 | (,v ,set-exp) | ||
| 451 | (,p ,(funcall setter | ||
| 452 | `(delq ,p ,getter))))))))))))))) | ||
| 453 | (ignore remove) ;;Silence byte-compiler. | ||
| 454 | (cdr (assoc key alist))) | ||
| 455 | |||
| 456 | (defmacro ses--letref (vars place &rest body) | 429 | (defmacro ses--letref (vars place &rest body) |
| 457 | (declare (indent 2) (debug (sexp form &rest body))) | 430 | (declare (indent 2) (debug (sexp form &rest body))) |
| 458 | (gv-letplace (getter setter) place | 431 | (gv-letplace (getter setter) place |
| @@ -467,18 +440,18 @@ When COL is omitted, CELL=ROW is a cell object. When COL is | |||
| 467 | present ROW and COL are the integer coordinates of the cell of | 440 | present ROW and COL are the integer coordinates of the cell of |
| 468 | interest." | 441 | interest." |
| 469 | (declare (debug t)) | 442 | (declare (debug t)) |
| 470 | `(ses--alist-get ,property-name | 443 | `(alist-get ,property-name |
| 471 | (ses-cell--properties | 444 | (ses-cell--properties |
| 472 | ,(if col `(ses-get-cell ,row ,col) row)))) | 445 | ,(if col `(ses-get-cell ,row ,col) row)))) |
| 473 | 446 | ||
| 474 | (defmacro ses-cell-property-pop (property-name row &optional col) | 447 | (defmacro ses-cell-property-pop (property-name row &optional col) |
| 475 | "From a CELL or a pair (ROW,COL), get and remove the property value of | 448 | "From a CELL or a pair (ROW,COL), get and remove the property value of |
| 476 | the corresponding cell with name PROPERTY-NAME." | 449 | the corresponding cell with name PROPERTY-NAME." |
| 477 | `(ses--letref (pget pset) | 450 | `(ses--letref (pget pset) |
| 478 | (ses--alist-get ,property-name | 451 | (alist-get ,property-name |
| 479 | (ses-cell--properties | 452 | (ses-cell--properties |
| 480 | ,(if col `(ses-get-cell ,row ,col) row)) | 453 | ,(if col `(ses-get-cell ,row ,col) row)) |
| 481 | t) | 454 | nil t) |
| 482 | (prog1 (pget) (pset nil)))) | 455 | (prog1 (pget) (pset nil)))) |
| 483 | 456 | ||
| 484 | (defmacro ses-cell-value (row &optional col) | 457 | (defmacro ses-cell-value (row &optional col) |
diff --git a/lisp/subr.el b/lisp/subr.el index 2bbc01d4533..581e52e8f9d 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -555,6 +555,15 @@ Elements of ALIST that are not conses are ignored." | |||
| 555 | (setq tail tail-cdr)))) | 555 | (setq tail tail-cdr)))) |
| 556 | alist) | 556 | alist) |
| 557 | 557 | ||
| 558 | (defun alist-get (key alist &optional default remove) | ||
| 559 | "Get the value associated to KEY in ALIST. | ||
| 560 | DEFAULT is the value to return if KEY is not found in ALIST. | ||
| 561 | REMOVE, if non-nil, means that when setting this element, we should | ||
| 562 | remove the entry if the new value is `eql' to DEFAULT." | ||
| 563 | (ignore remove) ;;Silence byte-compiler. | ||
| 564 | (let ((x (assq key alist))) | ||
| 565 | (if x (cdr x) default))) | ||
| 566 | |||
| 558 | (defun remove (elt seq) | 567 | (defun remove (elt seq) |
| 559 | "Return a copy of SEQ with all occurrences of ELT removed. | 568 | "Return a copy of SEQ with all occurrences of ELT removed. |
| 560 | SEQ must be a list, vector, or string. The comparison is done with `equal'." | 569 | SEQ must be a list, vector, or string. The comparison is done with `equal'." |
diff --git a/lisp/tempo.el b/lisp/tempo.el index 9b6cd75b313..15be01dcdf9 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el | |||
| @@ -611,11 +611,7 @@ function or string that is used by `\\[tempo-complete-tag]' to find a | |||
| 611 | string to match the tag against. It has the same definition as the | 611 | string to match the tag against. It has the same definition as the |
| 612 | variable `tempo-match-finder'. In this version, supplying a | 612 | variable `tempo-match-finder'. In this version, supplying a |
| 613 | COMPLETION-FUNCTION just sets `tempo-match-finder' locally." | 613 | COMPLETION-FUNCTION just sets `tempo-match-finder' locally." |
| 614 | (let ((old (assq tag-list tempo-local-tags))) | 614 | (setf (alist-get tag-list tempo-local-tags) completion-function) |
| 615 | (if old | ||
| 616 | (setcdr old completion-function) | ||
| 617 | (setq tempo-local-tags (cons (cons tag-list completion-function) | ||
| 618 | tempo-local-tags)))) | ||
| 619 | (if completion-function | 615 | (if completion-function |
| 620 | (setq tempo-match-finder completion-function)) | 616 | (setq tempo-match-finder completion-function)) |
| 621 | (tempo-invalidate-collection)) | 617 | (tempo-invalidate-collection)) |
diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 9d0954fc5dc..26cce418e45 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el | |||
| @@ -215,11 +215,9 @@ This might return nil if the event did not occur over a buffer." | |||
| 215 | "Change the value of KEY in alist ALIST to VALUE. | 215 | "Change the value of KEY in alist ALIST to VALUE. |
| 216 | If there's no association for KEY in ALIST, add one, otherwise | 216 | If there's no association for KEY in ALIST, add one, otherwise |
| 217 | change the existing association. Value is the resulting alist." | 217 | change the existing association. Value is the resulting alist." |
| 218 | (let ((param (assq key alist))) | 218 | (declare (obsolete "use (setf (alist-get ..) ..) instead" "25.1")) |
| 219 | (if (consp param) | 219 | (setf (alist-get key alist) value) |
| 220 | (setcdr param value) | 220 | alist) |
| 221 | (push (cons key value) alist)) | ||
| 222 | alist)) | ||
| 223 | 221 | ||
| 224 | (declare-function x-show-tip "xfns.c" | 222 | (declare-function x-show-tip "xfns.c" |
| 225 | (string &optional frame parms timeout dx dy)) | 223 | (string &optional frame parms timeout dx dy)) |
| @@ -244,10 +242,10 @@ in echo area." | |||
| 244 | (fg (face-attribute 'tooltip :foreground)) | 242 | (fg (face-attribute 'tooltip :foreground)) |
| 245 | (bg (face-attribute 'tooltip :background))) | 243 | (bg (face-attribute 'tooltip :background))) |
| 246 | (when (stringp fg) | 244 | (when (stringp fg) |
| 247 | (setq params (tooltip-set-param params 'foreground-color fg)) | 245 | (setf (alist-get 'foreground-color params) fg) |
| 248 | (setq params (tooltip-set-param params 'border-color fg))) | 246 | (setf (alist-get 'border-color params) fg)) |
| 249 | (when (stringp bg) | 247 | (when (stringp bg) |
| 250 | (setq params (tooltip-set-param params 'background-color bg))) | 248 | (setf (alist-get 'background-color params) bg)) |
| 251 | (x-show-tip (propertize text 'face 'tooltip) | 249 | (x-show-tip (propertize text 'face 'tooltip) |
| 252 | (selected-frame) | 250 | (selected-frame) |
| 253 | params | 251 | params |
diff --git a/lisp/winner.el b/lisp/winner.el index 1e32a7f4085..c202402a6e9 100644 --- a/lisp/winner.el +++ b/lisp/winner.el | |||
| @@ -112,10 +112,7 @@ You may want to include buffer names such as *Help*, *Apropos*, | |||
| 112 | ;; Save current configuration. | 112 | ;; Save current configuration. |
| 113 | ;; (Called below by `winner-save-old-configurations'). | 113 | ;; (Called below by `winner-save-old-configurations'). |
| 114 | (defun winner-remember () | 114 | (defun winner-remember () |
| 115 | (let ((entry (assq (selected-frame) winner-currents))) | 115 | (setf (alist-get (selected-frame) winner-currents) (winner-conf))) |
| 116 | (if entry (setcdr entry (winner-conf)) | ||
| 117 | (push (cons (selected-frame) (winner-conf)) | ||
| 118 | winner-currents)))) | ||
| 119 | 116 | ||
| 120 | ;; Consult `winner-currents'. | 117 | ;; Consult `winner-currents'. |
| 121 | (defun winner-configuration (&optional frame) | 118 | (defun winner-configuration (&optional frame) |