From ec79bdc53fd75ea48c1451b0d83b0b41a0345bc6 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 5 Mar 2018 20:37:34 +0200 Subject: [PATCH 01/14] Minor fix in Emacs manual's Glossary * doc/emacs/glossary.texi (Glossary): Fix outdated text about primary selection. Reported by Gijs Hillenius in emacs-manual-bugs@gnu.org. --- doc/emacs/glossary.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi index fd9e97f2d5f..148aafd1e51 100644 --- a/doc/emacs/glossary.texi +++ b/doc/emacs/glossary.texi @@ -1090,8 +1090,9 @@ The primary selection is one particular X selection (q.v.); it is the selection that most X applications use for transferring text to and from other applications. -The Emacs kill commands set the primary selection and the yank command -uses the primary selection when appropriate. @xref{Killing}. +The Emacs commands that mark or select text set the primary selection, +and clicking the mouse inserts text from the primary selection when +appropriate. @xref{Shift Selection}. @item Prompt A prompt is text used to ask you for input. Displaying a prompt From af4697faa1f5b643f63a9ea61aa205a4c1432e23 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Wed, 21 Feb 2018 11:15:37 +0100 Subject: [PATCH 02/14] Define if-let* and derivatives as aliases for if-let etc This commit reverts declaring `if-let' and `when-let' obsolete in favor of the new `if-let*' and `when-let*' versions because of the compiler warning mess (Bug#30039). Instead we make foo-let* aliases for foo-let. The old single-tuple variable spec case is still supported for backward compatibility. * lisp/emacs-lisp/subr-x.el (if-let, when-let): Don't declare obsolete. Tweak edebug specs. (and-let): Renamed from `and-let*' for compatibility with the names `if-let' and `when-let'. (if-let*, when-let*, and-let*): Define as aliases for `if-let', `when-let' and `and-let'. * test/lisp/emacs-lisp/subr-x-tests.el (if-let-single-tuple-case-test) (when-let-single-tuple-case-test): New tests for the single-binding tuple case. In the whole file, prefer the names without "*". --- etc/NEWS | 10 +- lisp/emacs-lisp/subr-x.el | 55 +++---- test/lisp/emacs-lisp/subr-x-tests.el | 234 ++++++++++++++------------- 3 files changed, 149 insertions(+), 150 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index eded00e6554..c88bec5a567 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1301,12 +1301,10 @@ current buffer or the self-insertion takes place within a comment. ** The alist 'ucs-names' is now a hash table. --- -** 'if-let' and 'when-let' are subsumed by 'if-let*' and 'when-let*'. -The incumbent 'if-let' and 'when-let' are now marked obsolete. -'if-let*' and 'when-let*' do not accept the single tuple special case. -New macro 'and-let*' is an implementation of the Scheme SRFI-2 syntax -of the same name. 'if-let*' and 'when-let*' now accept the same -binding syntax as 'and-let*'. +** The new macro 'and-let' is an implementation of the Scheme SRFI-2 +syntax. 'if-let' and 'when-let' now also accept the same binding +syntax as 'and-let'. 'if-let*', 'when-let*' and 'and-let*' are new +aliases for 'if-let', 'when-let' and 'and-let'. --- ** 'C-up', 'C-down', 'C-left' and 'C-right' are now defined in term diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 21dba377bf1..b2d7f0dec4f 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -121,7 +121,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol." binding)) bindings))) -(defmacro if-let* (varlist then &rest else) +(defmacro if-let (varlist then &rest else) "Bind variables according to VARLIST and eval THEN or ELSE. Each binding is evaluated in turn, and evaluation stops if a binding value is nil. If all are non-nil, the value of THEN is @@ -131,10 +131,18 @@ Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds SYMBOL to the value of VALUEFORM. An element can additionally be of the form (VALUEFORM), which is evaluated and checked for nil; i.e. SYMBOL can be omitted if only the test result is of -interest." +interest. + +As a special case, a VARLIST of the form (SYMBOL SOMETHING) is +treated like ((SYMBOL SOMETHING))." (declare (indent 2) - (debug ((&rest [&or symbolp (symbolp form) (form)]) + (debug ([&or (symbolp form) + (&rest [&or symbolp (symbolp form) (form)])] form body))) + (pcase varlist + (`(,(pred symbolp) ,_) + ;; the single-tuple syntax case, for backward compatibility + (cl-callf list varlist))) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) (if ,(caar (last varlist)) @@ -142,23 +150,23 @@ interest." ,@else)) `(let* () ,then))) -(defmacro when-let* (varlist &rest body) +(defmacro when-let (varlist &rest body) "Bind variables according to VARLIST and conditionally eval BODY. Each binding is evaluated in turn, and evaluation stops if a binding value is nil. If all are non-nil, the value of the last form in BODY is returned. -VARLIST is the same as in `if-let*'." - (declare (indent 1) (debug if-let*)) - (list 'if-let* varlist (macroexp-progn body))) +VARLIST is the same as in `if-let'." + (declare (indent 1) (debug ([&or (symbolp form) + (&rest [&or symbolp (symbolp form) (form)])] + body))) + (list 'if-let varlist (macroexp-progn body))) -(defmacro and-let* (varlist &rest body) +(defmacro and-let (varlist &rest body) "Bind variables according to VARLIST and conditionally eval BODY. -Like `when-let*', except if BODY is empty and all the bindings +Like `when-let', except if BODY is empty and all the bindings are non-nil, then the result is non-nil." - (declare (indent 1) - (debug ((&rest [&or symbolp (symbolp form) (form)]) - body))) + (declare (indent 1) (debug when-let)) (let (res) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) @@ -166,26 +174,9 @@ are non-nil, then the result is non-nil." ,@(or body `(,res)))) `(let* () ,@(or body '(t)))))) -(defmacro if-let (spec then &rest else) - "Bind variables according to SPEC and eval THEN or ELSE. -Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)." - (declare (indent 2) - (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) - (symbolp form)] - form body)) - (obsolete "use `if-let*' instead." "26.1")) - (when (and (<= (length spec) 2) - (not (listp (car spec)))) - ;; Adjust the single binding case - (setq spec (list spec))) - (list 'if-let* spec then (macroexp-progn else))) - -(defmacro when-let (spec &rest body) - "Bind variables according to SPEC and conditionally eval BODY. -Like `when-let*' except SPEC can have the form (SYMBOL VALUEFORM)." - (declare (indent 1) (debug if-let) - (obsolete "use `when-let*' instead." "26.1")) - (list 'if-let spec (macroexp-progn body))) +(defalias 'if-let* #'if-let) +(defalias 'when-let* #'when-let) +(defalias 'and-let* #'and-let) (defsubst hash-table-empty-p (hash-table) "Check whether HASH-TABLE is empty (has 0 elements)." diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index c9618f3c37f..a361718c9e2 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -28,13 +28,13 @@ (require 'subr-x) -;; `if-let*' tests +;; `if-let' tests -(ert-deftest subr-x-test-if-let*-single-binding-expansion () +(ert-deftest subr-x-test-if-let-single-binding-expansion () "Test single bindings are expanded properly." (should (equal (macroexpand - '(if-let* ((a 1)) + '(if-let ((a 1)) (- a) "no")) '(let* ((a (and t 1))) @@ -43,7 +43,7 @@ "no")))) (should (equal (macroexpand - '(if-let* (a) + '(if-let (a) (- a) "no")) '(let* ((a (and t a))) @@ -51,11 +51,11 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let*-single-symbol-expansion () +(ert-deftest subr-x-test-if-let-single-symbol-expansion () "Test single symbol bindings are expanded properly." (should (equal (macroexpand - '(if-let* (a) + '(if-let (a) (- a) "no")) '(let* ((a (and t a))) @@ -64,7 +64,7 @@ "no")))) (should (equal (macroexpand - '(if-let* (a b c) + '(if-let (a b c) (- a) "no")) '(let* ((a (and t a)) @@ -75,7 +75,7 @@ "no")))) (should (equal (macroexpand - '(if-let* (a (b 2) c) + '(if-let (a (b 2) c) (- a) "no")) '(let* ((a (and t a)) @@ -85,11 +85,11 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let*-nil-related-expansion () +(ert-deftest subr-x-test-if-let-nil-related-expansion () "Test nil is processed properly." (should (equal (macroexpand - '(if-let* (nil) + '(if-let (nil) (- a) "no")) '(let* ((nil (and t nil))) @@ -98,7 +98,7 @@ "no")))) (should (equal (macroexpand - '(if-let* ((a 1) nil (b 2)) + '(if-let ((a 1) nil (b 2)) (- a) "no")) '(let* ((a (and t 1)) @@ -108,106 +108,106 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let*-malformed-binding () +(ert-deftest subr-x-test-if-let-malformed-binding () "Test malformed bindings trigger errors." (should-error (macroexpand - '(if-let* (_ (a 1 1) (b 2) (c 3) d) + '(if-let (_ (a 1 1) (b 2) (c 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let* (_ (a 1) (b 2 2) (c 3) d) + '(if-let (_ (a 1) (b 2 2) (c 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let* (_ (a 1) (b 2) (c 3 3) d) + '(if-let (_ (a 1) (b 2) (c 3 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let* ((a 1 1)) + '(if-let ((a 1 1)) (- a) "no")) :type 'error)) -(ert-deftest subr-x-test-if-let*-true () +(ert-deftest subr-x-test-if-let-true () "Test `if-let' with truthy bindings." (should (equal - (if-let* ((a 1)) + (if-let ((a 1)) a "no") 1)) (should (equal - (if-let* ((a 1) (b 2) (c 3)) + (if-let ((a 1) (b 2) (c 3)) (list a b c) "no") (list 1 2 3)))) -(ert-deftest subr-x-test-if-let*-false () +(ert-deftest subr-x-test-if-let-false () "Test `if-let' with falsie bindings." (should (equal - (if-let* ((a nil)) + (if-let ((a nil)) (list a b c) "no") "no")) (should (equal - (if-let* ((a nil) (b 2) (c 3)) + (if-let ((a nil) (b 2) (c 3)) (list a b c) "no") "no")) (should (equal - (if-let* ((a 1) (b nil) (c 3)) + (if-let ((a 1) (b nil) (c 3)) (list a b c) "no") "no")) (should (equal - (if-let* ((a 1) (b 2) (c nil)) + (if-let ((a 1) (b 2) (c nil)) (list a b c) "no") "no")) (should (equal (let (z) - (if-let* (z (a 1) (b 2) (c 3)) + (if-let (z (a 1) (b 2) (c 3)) (list a b c) "no")) "no")) (should (equal (let (d) - (if-let* ((a 1) (b 2) (c 3) d) + (if-let ((a 1) (b 2) (c 3) d) (list a b c) "no")) "no"))) -(ert-deftest subr-x-test-if-let*-bound-references () +(ert-deftest subr-x-test-if-let-bound-references () "Test `if-let' bindings can refer to already bound symbols." (should (equal - (if-let* ((a (1+ 0)) (b (1+ a)) (c (1+ b))) + (if-let ((a (1+ 0)) (b (1+ a)) (c (1+ b))) (list a b c) "no") (list 1 2 3)))) -(ert-deftest subr-x-test-if-let*-and-laziness-is-preserved () +(ert-deftest subr-x-test-if-let-and-laziness-is-preserved () "Test `if-let' respects `and' laziness." (let (a-called b-called c-called) (should (equal - (if-let* ((a nil) - (b (setq b-called t)) - (c (setq c-called t))) + (if-let ((a nil) + (b (setq b-called t)) + (c (setq c-called t))) "yes" (list a-called b-called c-called)) (list nil nil nil)))) (let (a-called b-called c-called) (should (equal - (if-let* ((a (setq a-called t)) - (b nil) - (c (setq c-called t))) + (if-let ((a (setq a-called t)) + (b nil) + (c (setq c-called t))) "yes" (list a-called b-called c-called)) (list t nil nil)))) (let (a-called b-called c-called) (should (equal - (if-let* ((a (setq a-called t)) + (if-let ((a (setq a-called t)) (b (setq b-called t)) (c nil) (d (setq c-called t))) @@ -215,14 +215,19 @@ (list a-called b-called c-called)) (list t t nil))))) - -;; `when-let*' tests +(defun if-let-single-tuple-case-test () + "Test the BINDING-SPEC == (SYMBOL SOMETHING) case." + (should (equal (if-let (a 1) (1+ a)) 2)) + (should (equal (let ((b 2)) (if-let (a b) a)) 2))) -(ert-deftest subr-x-test-when-let*-body-expansion () + +;; `when-let' tests + +(ert-deftest subr-x-test-when-let-body-expansion () "Test body allows for multiple sexps wrapping with progn." (should (equal (macroexpand - '(when-let* ((a 1)) + '(when-let ((a 1)) (message "opposite") (- a))) '(let* ((a (and t 1))) @@ -231,18 +236,18 @@ (message "opposite") (- a))))))) -(ert-deftest subr-x-test-when-let*-single-symbol-expansion () +(ert-deftest subr-x-test-when-let-single-symbol-expansion () "Test single symbol bindings are expanded properly." (should (equal (macroexpand - '(when-let* (a) + '(when-let (a) (- a))) '(let* ((a (and t a))) (if a (- a))))) (should (equal (macroexpand - '(when-let* (a b c) + '(when-let (a b c) (- a))) '(let* ((a (and t a)) (b (and a b)) @@ -251,7 +256,7 @@ (- a))))) (should (equal (macroexpand - '(when-let* (a (b 2) c) + '(when-let (a (b 2) c) (- a))) '(let* ((a (and t a)) (b (and a 2)) @@ -259,18 +264,18 @@ (if c (- a)))))) -(ert-deftest subr-x-test-when-let*-nil-related-expansion () +(ert-deftest subr-x-test-when-let-nil-related-expansion () "Test nil is processed properly." (should (equal (macroexpand - '(when-let* (nil) + '(when-let (nil) (- a))) '(let* ((nil (and t nil))) (if nil (- a))))) (should (equal (macroexpand - '(when-let* ((a 1) nil (b 2)) + '(when-let ((a 1) nil (b 2)) (- a))) '(let* ((a (and t 1)) (nil (and a nil)) @@ -278,173 +283,178 @@ (if b (- a)))))) -(ert-deftest subr-x-test-when-let*-malformed-binding () +(ert-deftest subr-x-test-when-let-malformed-binding () "Test malformed bindings trigger errors." (should-error (macroexpand - '(when-let* (_ (a 1 1) (b 2) (c 3) d) + '(when-let (_ (a 1 1) (b 2) (c 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let* (_ (a 1) (b 2 2) (c 3) d) + '(when-let (_ (a 1) (b 2 2) (c 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let* (_ (a 1) (b 2) (c 3 3) d) + '(when-let (_ (a 1) (b 2) (c 3 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let* ((a 1 1)) + '(when-let ((a 1 1)) (- a))) :type 'error)) -(ert-deftest subr-x-test-when-let*-true () +(ert-deftest subr-x-test-when-let-true () "Test `when-let' with truthy bindings." (should (equal - (when-let* ((a 1)) + (when-let ((a 1)) a) 1)) (should (equal - (when-let* ((a 1) (b 2) (c 3)) + (when-let ((a 1) (b 2) (c 3)) (list a b c)) (list 1 2 3)))) -(ert-deftest subr-x-test-when-let*-false () +(ert-deftest subr-x-test-when-let-false () "Test `when-let' with falsie bindings." (should (equal - (when-let* ((a nil)) + (when-let ((a nil)) (list a b c) "no") nil)) (should (equal - (when-let* ((a nil) (b 2) (c 3)) + (when-let ((a nil) (b 2) (c 3)) (list a b c) "no") nil)) (should (equal - (when-let* ((a 1) (b nil) (c 3)) + (when-let ((a 1) (b nil) (c 3)) (list a b c) "no") nil)) (should (equal - (when-let* ((a 1) (b 2) (c nil)) + (when-let ((a 1) (b 2) (c nil)) (list a b c) "no") nil)) (should (equal (let (z) - (when-let* (z (a 1) (b 2) (c 3)) + (when-let (z (a 1) (b 2) (c 3)) (list a b c) "no")) nil)) (should (equal (let (d) - (when-let* ((a 1) (b 2) (c 3) d) + (when-let ((a 1) (b 2) (c 3) d) (list a b c) "no")) nil))) -(ert-deftest subr-x-test-when-let*-bound-references () +(ert-deftest subr-x-test-when-let-bound-references () "Test `when-let' bindings can refer to already bound symbols." (should (equal - (when-let* ((a (1+ 0)) (b (1+ a)) (c (1+ b))) + (when-let ((a (1+ 0)) (b (1+ a)) (c (1+ b))) (list a b c)) (list 1 2 3)))) -(ert-deftest subr-x-test-when-let*-and-laziness-is-preserved () +(ert-deftest subr-x-test-when-let-and-laziness-is-preserved () "Test `when-let' respects `and' laziness." (let (a-called b-called c-called) (should (equal (progn - (when-let* ((a nil) - (b (setq b-called t)) - (c (setq c-called t))) + (when-let ((a nil) + (b (setq b-called t)) + (c (setq c-called t))) "yes") (list a-called b-called c-called)) (list nil nil nil)))) (let (a-called b-called c-called) (should (equal (progn - (when-let* ((a (setq a-called t)) - (b nil) - (c (setq c-called t))) + (when-let ((a (setq a-called t)) + (b nil) + (c (setq c-called t))) "yes") (list a-called b-called c-called)) (list t nil nil)))) (let (a-called b-called c-called) (should (equal (progn - (when-let* ((a (setq a-called t)) - (b (setq b-called t)) - (c nil) - (d (setq c-called t))) + (when-let ((a (setq a-called t)) + (b (setq b-called t)) + (c nil) + (d (setq c-called t))) "yes") (list a-called b-called c-called)) (list t t nil))))) +(defun when-let-single-tuple-case-test () + "Test the BINDING-SPEC == (SYMBOL SOMETHING) case." + (should (equal (when-let (a 1) (1+ a)) 2)) + (should (equal (let ((b 2)) (when-let (a b) a)) 2))) + -;; `and-let*' tests +;; `and-let' tests ;; Adapted from the Guile tests ;; https://git.savannah.gnu.org/cgit/guile.git/tree/test-suite/tests/srfi-2.test -(ert-deftest subr-x-and-let*-test-empty-varlist () - (should (equal 1 (and-let* () 1))) - (should (equal 2 (and-let* () 1 2))) - (should (equal t (and-let* ())))) +(ert-deftest subr-x-and-let-test-empty-varlist () + (should (equal 1 (and-let () 1))) + (should (equal 2 (and-let () 1 2))) + (should (equal t (and-let ())))) -(ert-deftest subr-x-and-let*-test-group-1 () - (should (equal nil (let ((x nil)) (and-let* (x))))) - (should (equal 1 (let ((x 1)) (and-let* (x))))) - (should (equal nil (and-let* ((x nil))))) - (should (equal 1 (and-let* ((x 1))))) +(ert-deftest subr-x-and-let-test-group-1 () + (should (equal nil (let ((x nil)) (and-let (x))))) + (should (equal 1 (let ((x 1)) (and-let (x))))) + (should (equal nil (and-let ((x nil))))) + (should (equal 1 (and-let ((x 1))))) ;; The error doesn't trigger when compiled: the compiler will give ;; a warning and then drop the erroneous code. Therefore, use ;; `eval' to avoid compilation. - (should-error (eval '(and-let* (nil (x 1))) lexical-binding) + (should-error (eval '(and-let (nil (x 1))) lexical-binding) :type 'setting-constant) - (should (equal nil (and-let* ((nil) (x 1))))) - (should-error (eval '(and-let* (2 (x 1))) lexical-binding) + (should (equal nil (and-let ((nil) (x 1))))) + (should-error (eval '(and-let (2 (x 1))) lexical-binding) :type 'wrong-type-argument) - (should (equal 1 (and-let* ((2) (x 1))))) - (should (equal 2 (and-let* ((x 1) (2))))) - (should (equal nil (let ((x nil)) (and-let* (x) x)))) - (should (equal "" (let ((x "")) (and-let* (x) x)))) - (should (equal "" (let ((x "")) (and-let* (x))))) - (should (equal 2 (let ((x 1)) (and-let* (x) (+ x 1))))) - (should (equal nil (let ((x nil)) (and-let* (x) (+ x 1))))) - (should (equal 2 (let ((x 1)) (and-let* (((> x 0))) (+ x 1))))) - (should (equal t (let ((x 1)) (and-let* (((> x 0))))))) - (should (equal nil (let ((x 0)) (and-let* (((> x 0))) (+ x 1))))) + (should (equal 1 (and-let ((2) (x 1))))) + (should (equal 2 (and-let ((x 1) (2))))) + (should (equal nil (let ((x nil)) (and-let (x) x)))) + (should (equal "" (let ((x "")) (and-let (x) x)))) + (should (equal "" (let ((x "")) (and-let (x))))) + (should (equal 2 (let ((x 1)) (and-let (x) (+ x 1))))) + (should (equal nil (let ((x nil)) (and-let (x) (+ x 1))))) + (should (equal 2 (let ((x 1)) (and-let (((> x 0))) (+ x 1))))) + (should (equal t (let ((x 1)) (and-let (((> x 0))))))) + (should (equal nil (let ((x 0)) (and-let (((> x 0))) (+ x 1))))) (should (equal 3 - (let ((x 1)) (and-let* (((> x 0)) (x (+ x 1))) (+ x 1)))))) + (let ((x 1)) (and-let (((> x 0)) (x (+ x 1))) (+ x 1)))))) -(ert-deftest subr-x-and-let*-test-rebind () +(ert-deftest subr-x-and-let-test-rebind () (should (equal 4 (let ((x 1)) - (and-let* (((> x 0)) (x (+ x 1)) (x (+ x 1))) (+ x 1)))))) + (and-let (((> x 0)) (x (+ x 1)) (x (+ x 1))) (+ x 1)))))) -(ert-deftest subr-x-and-let*-test-group-2 () +(ert-deftest subr-x-and-let-test-group-2 () (should - (equal 2 (let ((x 1)) (and-let* (x ((> x 0))) (+ x 1))))) + (equal 2 (let ((x 1)) (and-let (x ((> x 0))) (+ x 1))))) (should - (equal 2 (let ((x 1)) (and-let* (((progn x)) ((> x 0))) (+ x 1))))) - (should (equal nil (let ((x 0)) (and-let* (x ((> x 0))) (+ x 1))))) - (should (equal nil (let ((x nil)) (and-let* (x ((> x 0))) (+ x 1))))) + (equal 2 (let ((x 1)) (and-let (((progn x)) ((> x 0))) (+ x 1))))) + (should (equal nil (let ((x 0)) (and-let (x ((> x 0))) (+ x 1))))) + (should (equal nil (let ((x nil)) (and-let (x ((> x 0))) (+ x 1))))) (should - (equal nil (let ((x nil)) (and-let* (((progn x)) ((> x 0))) (+ x 1)))))) + (equal nil (let ((x nil)) (and-let (((progn x)) ((> x 0))) (+ x 1)))))) -(ert-deftest subr-x-and-let*-test-group-3 () +(ert-deftest subr-x-and-let-test-group-3 () (should - (equal nil (let ((x 1)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) + (equal nil (let ((x 1)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) (should - (equal nil (let ((x 0)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) + (equal nil (let ((x 0)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) (should (equal nil - (let ((x nil)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) + (let ((x nil)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) (should (equal (/ 3.0 2) - (let ((x 3.0)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y)))))) + (let ((x 3.0)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y)))))) From f6bd7e06861142371994ff9ce54dd62573809fa5 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 6 Mar 2018 18:28:51 +0100 Subject: [PATCH 03/14] Revert last commit This reverts commit af4697faa1f5b643f63a9ea61aa205a4c1432e23. It's too late for this to be in the release. --- etc/NEWS | 10 +- lisp/emacs-lisp/subr-x.el | 55 ++++--- test/lisp/emacs-lisp/subr-x-tests.el | 232 +++++++++++++-------------- 3 files changed, 149 insertions(+), 148 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c88bec5a567..eded00e6554 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1301,10 +1301,12 @@ current buffer or the self-insertion takes place within a comment. ** The alist 'ucs-names' is now a hash table. --- -** The new macro 'and-let' is an implementation of the Scheme SRFI-2 -syntax. 'if-let' and 'when-let' now also accept the same binding -syntax as 'and-let'. 'if-let*', 'when-let*' and 'and-let*' are new -aliases for 'if-let', 'when-let' and 'and-let'. +** 'if-let' and 'when-let' are subsumed by 'if-let*' and 'when-let*'. +The incumbent 'if-let' and 'when-let' are now marked obsolete. +'if-let*' and 'when-let*' do not accept the single tuple special case. +New macro 'and-let*' is an implementation of the Scheme SRFI-2 syntax +of the same name. 'if-let*' and 'when-let*' now accept the same +binding syntax as 'and-let*'. --- ** 'C-up', 'C-down', 'C-left' and 'C-right' are now defined in term diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index b2d7f0dec4f..21dba377bf1 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -121,7 +121,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol." binding)) bindings))) -(defmacro if-let (varlist then &rest else) +(defmacro if-let* (varlist then &rest else) "Bind variables according to VARLIST and eval THEN or ELSE. Each binding is evaluated in turn, and evaluation stops if a binding value is nil. If all are non-nil, the value of THEN is @@ -131,18 +131,10 @@ Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds SYMBOL to the value of VALUEFORM. An element can additionally be of the form (VALUEFORM), which is evaluated and checked for nil; i.e. SYMBOL can be omitted if only the test result is of -interest. - -As a special case, a VARLIST of the form (SYMBOL SOMETHING) is -treated like ((SYMBOL SOMETHING))." +interest." (declare (indent 2) - (debug ([&or (symbolp form) - (&rest [&or symbolp (symbolp form) (form)])] + (debug ((&rest [&or symbolp (symbolp form) (form)]) form body))) - (pcase varlist - (`(,(pred symbolp) ,_) - ;; the single-tuple syntax case, for backward compatibility - (cl-callf list varlist))) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) (if ,(caar (last varlist)) @@ -150,23 +142,23 @@ treated like ((SYMBOL SOMETHING))." ,@else)) `(let* () ,then))) -(defmacro when-let (varlist &rest body) +(defmacro when-let* (varlist &rest body) "Bind variables according to VARLIST and conditionally eval BODY. Each binding is evaluated in turn, and evaluation stops if a binding value is nil. If all are non-nil, the value of the last form in BODY is returned. -VARLIST is the same as in `if-let'." - (declare (indent 1) (debug ([&or (symbolp form) - (&rest [&or symbolp (symbolp form) (form)])] - body))) - (list 'if-let varlist (macroexp-progn body))) +VARLIST is the same as in `if-let*'." + (declare (indent 1) (debug if-let*)) + (list 'if-let* varlist (macroexp-progn body))) -(defmacro and-let (varlist &rest body) +(defmacro and-let* (varlist &rest body) "Bind variables according to VARLIST and conditionally eval BODY. -Like `when-let', except if BODY is empty and all the bindings +Like `when-let*', except if BODY is empty and all the bindings are non-nil, then the result is non-nil." - (declare (indent 1) (debug when-let)) + (declare (indent 1) + (debug ((&rest [&or symbolp (symbolp form) (form)]) + body))) (let (res) (if varlist `(let* ,(setq varlist (internal--build-bindings varlist)) @@ -174,9 +166,26 @@ are non-nil, then the result is non-nil." ,@(or body `(,res)))) `(let* () ,@(or body '(t)))))) -(defalias 'if-let* #'if-let) -(defalias 'when-let* #'when-let) -(defalias 'and-let* #'and-let) +(defmacro if-let (spec then &rest else) + "Bind variables according to SPEC and eval THEN or ELSE. +Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)." + (declare (indent 2) + (debug ([&or (&rest [&or symbolp (symbolp form) (form)]) + (symbolp form)] + form body)) + (obsolete "use `if-let*' instead." "26.1")) + (when (and (<= (length spec) 2) + (not (listp (car spec)))) + ;; Adjust the single binding case + (setq spec (list spec))) + (list 'if-let* spec then (macroexp-progn else))) + +(defmacro when-let (spec &rest body) + "Bind variables according to SPEC and conditionally eval BODY. +Like `when-let*' except SPEC can have the form (SYMBOL VALUEFORM)." + (declare (indent 1) (debug if-let) + (obsolete "use `when-let*' instead." "26.1")) + (list 'if-let spec (macroexp-progn body))) (defsubst hash-table-empty-p (hash-table) "Check whether HASH-TABLE is empty (has 0 elements)." diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index a361718c9e2..c9618f3c37f 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -28,13 +28,13 @@ (require 'subr-x) -;; `if-let' tests +;; `if-let*' tests -(ert-deftest subr-x-test-if-let-single-binding-expansion () +(ert-deftest subr-x-test-if-let*-single-binding-expansion () "Test single bindings are expanded properly." (should (equal (macroexpand - '(if-let ((a 1)) + '(if-let* ((a 1)) (- a) "no")) '(let* ((a (and t 1))) @@ -43,7 +43,7 @@ "no")))) (should (equal (macroexpand - '(if-let (a) + '(if-let* (a) (- a) "no")) '(let* ((a (and t a))) @@ -51,11 +51,11 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let-single-symbol-expansion () +(ert-deftest subr-x-test-if-let*-single-symbol-expansion () "Test single symbol bindings are expanded properly." (should (equal (macroexpand - '(if-let (a) + '(if-let* (a) (- a) "no")) '(let* ((a (and t a))) @@ -64,7 +64,7 @@ "no")))) (should (equal (macroexpand - '(if-let (a b c) + '(if-let* (a b c) (- a) "no")) '(let* ((a (and t a)) @@ -75,7 +75,7 @@ "no")))) (should (equal (macroexpand - '(if-let (a (b 2) c) + '(if-let* (a (b 2) c) (- a) "no")) '(let* ((a (and t a)) @@ -85,11 +85,11 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let-nil-related-expansion () +(ert-deftest subr-x-test-if-let*-nil-related-expansion () "Test nil is processed properly." (should (equal (macroexpand - '(if-let (nil) + '(if-let* (nil) (- a) "no")) '(let* ((nil (and t nil))) @@ -98,7 +98,7 @@ "no")))) (should (equal (macroexpand - '(if-let ((a 1) nil (b 2)) + '(if-let* ((a 1) nil (b 2)) (- a) "no")) '(let* ((a (and t 1)) @@ -108,106 +108,106 @@ (- a) "no"))))) -(ert-deftest subr-x-test-if-let-malformed-binding () +(ert-deftest subr-x-test-if-let*-malformed-binding () "Test malformed bindings trigger errors." (should-error (macroexpand - '(if-let (_ (a 1 1) (b 2) (c 3) d) + '(if-let* (_ (a 1 1) (b 2) (c 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let (_ (a 1) (b 2 2) (c 3) d) + '(if-let* (_ (a 1) (b 2 2) (c 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let (_ (a 1) (b 2) (c 3 3) d) + '(if-let* (_ (a 1) (b 2) (c 3 3) d) (- a) "no")) :type 'error) (should-error (macroexpand - '(if-let ((a 1 1)) + '(if-let* ((a 1 1)) (- a) "no")) :type 'error)) -(ert-deftest subr-x-test-if-let-true () +(ert-deftest subr-x-test-if-let*-true () "Test `if-let' with truthy bindings." (should (equal - (if-let ((a 1)) + (if-let* ((a 1)) a "no") 1)) (should (equal - (if-let ((a 1) (b 2) (c 3)) + (if-let* ((a 1) (b 2) (c 3)) (list a b c) "no") (list 1 2 3)))) -(ert-deftest subr-x-test-if-let-false () +(ert-deftest subr-x-test-if-let*-false () "Test `if-let' with falsie bindings." (should (equal - (if-let ((a nil)) + (if-let* ((a nil)) (list a b c) "no") "no")) (should (equal - (if-let ((a nil) (b 2) (c 3)) + (if-let* ((a nil) (b 2) (c 3)) (list a b c) "no") "no")) (should (equal - (if-let ((a 1) (b nil) (c 3)) + (if-let* ((a 1) (b nil) (c 3)) (list a b c) "no") "no")) (should (equal - (if-let ((a 1) (b 2) (c nil)) + (if-let* ((a 1) (b 2) (c nil)) (list a b c) "no") "no")) (should (equal (let (z) - (if-let (z (a 1) (b 2) (c 3)) + (if-let* (z (a 1) (b 2) (c 3)) (list a b c) "no")) "no")) (should (equal (let (d) - (if-let ((a 1) (b 2) (c 3) d) + (if-let* ((a 1) (b 2) (c 3) d) (list a b c) "no")) "no"))) -(ert-deftest subr-x-test-if-let-bound-references () +(ert-deftest subr-x-test-if-let*-bound-references () "Test `if-let' bindings can refer to already bound symbols." (should (equal - (if-let ((a (1+ 0)) (b (1+ a)) (c (1+ b))) + (if-let* ((a (1+ 0)) (b (1+ a)) (c (1+ b))) (list a b c) "no") (list 1 2 3)))) -(ert-deftest subr-x-test-if-let-and-laziness-is-preserved () +(ert-deftest subr-x-test-if-let*-and-laziness-is-preserved () "Test `if-let' respects `and' laziness." (let (a-called b-called c-called) (should (equal - (if-let ((a nil) - (b (setq b-called t)) - (c (setq c-called t))) + (if-let* ((a nil) + (b (setq b-called t)) + (c (setq c-called t))) "yes" (list a-called b-called c-called)) (list nil nil nil)))) (let (a-called b-called c-called) (should (equal - (if-let ((a (setq a-called t)) - (b nil) - (c (setq c-called t))) + (if-let* ((a (setq a-called t)) + (b nil) + (c (setq c-called t))) "yes" (list a-called b-called c-called)) (list t nil nil)))) (let (a-called b-called c-called) (should (equal - (if-let ((a (setq a-called t)) + (if-let* ((a (setq a-called t)) (b (setq b-called t)) (c nil) (d (setq c-called t))) @@ -215,19 +215,14 @@ (list a-called b-called c-called)) (list t t nil))))) -(defun if-let-single-tuple-case-test () - "Test the BINDING-SPEC == (SYMBOL SOMETHING) case." - (should (equal (if-let (a 1) (1+ a)) 2)) - (should (equal (let ((b 2)) (if-let (a b) a)) 2))) - -;; `when-let' tests +;; `when-let*' tests -(ert-deftest subr-x-test-when-let-body-expansion () +(ert-deftest subr-x-test-when-let*-body-expansion () "Test body allows for multiple sexps wrapping with progn." (should (equal (macroexpand - '(when-let ((a 1)) + '(when-let* ((a 1)) (message "opposite") (- a))) '(let* ((a (and t 1))) @@ -236,18 +231,18 @@ (message "opposite") (- a))))))) -(ert-deftest subr-x-test-when-let-single-symbol-expansion () +(ert-deftest subr-x-test-when-let*-single-symbol-expansion () "Test single symbol bindings are expanded properly." (should (equal (macroexpand - '(when-let (a) + '(when-let* (a) (- a))) '(let* ((a (and t a))) (if a (- a))))) (should (equal (macroexpand - '(when-let (a b c) + '(when-let* (a b c) (- a))) '(let* ((a (and t a)) (b (and a b)) @@ -256,7 +251,7 @@ (- a))))) (should (equal (macroexpand - '(when-let (a (b 2) c) + '(when-let* (a (b 2) c) (- a))) '(let* ((a (and t a)) (b (and a 2)) @@ -264,18 +259,18 @@ (if c (- a)))))) -(ert-deftest subr-x-test-when-let-nil-related-expansion () +(ert-deftest subr-x-test-when-let*-nil-related-expansion () "Test nil is processed properly." (should (equal (macroexpand - '(when-let (nil) + '(when-let* (nil) (- a))) '(let* ((nil (and t nil))) (if nil (- a))))) (should (equal (macroexpand - '(when-let ((a 1) nil (b 2)) + '(when-let* ((a 1) nil (b 2)) (- a))) '(let* ((a (and t 1)) (nil (and a nil)) @@ -283,178 +278,173 @@ (if b (- a)))))) -(ert-deftest subr-x-test-when-let-malformed-binding () +(ert-deftest subr-x-test-when-let*-malformed-binding () "Test malformed bindings trigger errors." (should-error (macroexpand - '(when-let (_ (a 1 1) (b 2) (c 3) d) + '(when-let* (_ (a 1 1) (b 2) (c 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let (_ (a 1) (b 2 2) (c 3) d) + '(when-let* (_ (a 1) (b 2 2) (c 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let (_ (a 1) (b 2) (c 3 3) d) + '(when-let* (_ (a 1) (b 2) (c 3 3) d) (- a))) :type 'error) (should-error (macroexpand - '(when-let ((a 1 1)) + '(when-let* ((a 1 1)) (- a))) :type 'error)) -(ert-deftest subr-x-test-when-let-true () +(ert-deftest subr-x-test-when-let*-true () "Test `when-let' with truthy bindings." (should (equal - (when-let ((a 1)) + (when-let* ((a 1)) a) 1)) (should (equal - (when-let ((a 1) (b 2) (c 3)) + (when-let* ((a 1) (b 2) (c 3)) (list a b c)) (list 1 2 3)))) -(ert-deftest subr-x-test-when-let-false () +(ert-deftest subr-x-test-when-let*-false () "Test `when-let' with falsie bindings." (should (equal - (when-let ((a nil)) + (when-let* ((a nil)) (list a b c) "no") nil)) (should (equal - (when-let ((a nil) (b 2) (c 3)) + (when-let* ((a nil) (b 2) (c 3)) (list a b c) "no") nil)) (should (equal - (when-let ((a 1) (b nil) (c 3)) + (when-let* ((a 1) (b nil) (c 3)) (list a b c) "no") nil)) (should (equal - (when-let ((a 1) (b 2) (c nil)) + (when-let* ((a 1) (b 2) (c nil)) (list a b c) "no") nil)) (should (equal (let (z) - (when-let (z (a 1) (b 2) (c 3)) + (when-let* (z (a 1) (b 2) (c 3)) (list a b c) "no")) nil)) (should (equal (let (d) - (when-let ((a 1) (b 2) (c 3) d) + (when-let* ((a 1) (b 2) (c 3) d) (list a b c) "no")) nil))) -(ert-deftest subr-x-test-when-let-bound-references () +(ert-deftest subr-x-test-when-let*-bound-references () "Test `when-let' bindings can refer to already bound symbols." (should (equal - (when-let ((a (1+ 0)) (b (1+ a)) (c (1+ b))) + (when-let* ((a (1+ 0)) (b (1+ a)) (c (1+ b))) (list a b c)) (list 1 2 3)))) -(ert-deftest subr-x-test-when-let-and-laziness-is-preserved () +(ert-deftest subr-x-test-when-let*-and-laziness-is-preserved () "Test `when-let' respects `and' laziness." (let (a-called b-called c-called) (should (equal (progn - (when-let ((a nil) - (b (setq b-called t)) - (c (setq c-called t))) + (when-let* ((a nil) + (b (setq b-called t)) + (c (setq c-called t))) "yes") (list a-called b-called c-called)) (list nil nil nil)))) (let (a-called b-called c-called) (should (equal (progn - (when-let ((a (setq a-called t)) - (b nil) - (c (setq c-called t))) + (when-let* ((a (setq a-called t)) + (b nil) + (c (setq c-called t))) "yes") (list a-called b-called c-called)) (list t nil nil)))) (let (a-called b-called c-called) (should (equal (progn - (when-let ((a (setq a-called t)) - (b (setq b-called t)) - (c nil) - (d (setq c-called t))) + (when-let* ((a (setq a-called t)) + (b (setq b-called t)) + (c nil) + (d (setq c-called t))) "yes") (list a-called b-called c-called)) (list t t nil))))) -(defun when-let-single-tuple-case-test () - "Test the BINDING-SPEC == (SYMBOL SOMETHING) case." - (should (equal (when-let (a 1) (1+ a)) 2)) - (should (equal (let ((b 2)) (when-let (a b) a)) 2))) - -;; `and-let' tests +;; `and-let*' tests ;; Adapted from the Guile tests ;; https://git.savannah.gnu.org/cgit/guile.git/tree/test-suite/tests/srfi-2.test -(ert-deftest subr-x-and-let-test-empty-varlist () - (should (equal 1 (and-let () 1))) - (should (equal 2 (and-let () 1 2))) - (should (equal t (and-let ())))) +(ert-deftest subr-x-and-let*-test-empty-varlist () + (should (equal 1 (and-let* () 1))) + (should (equal 2 (and-let* () 1 2))) + (should (equal t (and-let* ())))) -(ert-deftest subr-x-and-let-test-group-1 () - (should (equal nil (let ((x nil)) (and-let (x))))) - (should (equal 1 (let ((x 1)) (and-let (x))))) - (should (equal nil (and-let ((x nil))))) - (should (equal 1 (and-let ((x 1))))) +(ert-deftest subr-x-and-let*-test-group-1 () + (should (equal nil (let ((x nil)) (and-let* (x))))) + (should (equal 1 (let ((x 1)) (and-let* (x))))) + (should (equal nil (and-let* ((x nil))))) + (should (equal 1 (and-let* ((x 1))))) ;; The error doesn't trigger when compiled: the compiler will give ;; a warning and then drop the erroneous code. Therefore, use ;; `eval' to avoid compilation. - (should-error (eval '(and-let (nil (x 1))) lexical-binding) + (should-error (eval '(and-let* (nil (x 1))) lexical-binding) :type 'setting-constant) - (should (equal nil (and-let ((nil) (x 1))))) - (should-error (eval '(and-let (2 (x 1))) lexical-binding) + (should (equal nil (and-let* ((nil) (x 1))))) + (should-error (eval '(and-let* (2 (x 1))) lexical-binding) :type 'wrong-type-argument) - (should (equal 1 (and-let ((2) (x 1))))) - (should (equal 2 (and-let ((x 1) (2))))) - (should (equal nil (let ((x nil)) (and-let (x) x)))) - (should (equal "" (let ((x "")) (and-let (x) x)))) - (should (equal "" (let ((x "")) (and-let (x))))) - (should (equal 2 (let ((x 1)) (and-let (x) (+ x 1))))) - (should (equal nil (let ((x nil)) (and-let (x) (+ x 1))))) - (should (equal 2 (let ((x 1)) (and-let (((> x 0))) (+ x 1))))) - (should (equal t (let ((x 1)) (and-let (((> x 0))))))) - (should (equal nil (let ((x 0)) (and-let (((> x 0))) (+ x 1))))) + (should (equal 1 (and-let* ((2) (x 1))))) + (should (equal 2 (and-let* ((x 1) (2))))) + (should (equal nil (let ((x nil)) (and-let* (x) x)))) + (should (equal "" (let ((x "")) (and-let* (x) x)))) + (should (equal "" (let ((x "")) (and-let* (x))))) + (should (equal 2 (let ((x 1)) (and-let* (x) (+ x 1))))) + (should (equal nil (let ((x nil)) (and-let* (x) (+ x 1))))) + (should (equal 2 (let ((x 1)) (and-let* (((> x 0))) (+ x 1))))) + (should (equal t (let ((x 1)) (and-let* (((> x 0))))))) + (should (equal nil (let ((x 0)) (and-let* (((> x 0))) (+ x 1))))) (should (equal 3 - (let ((x 1)) (and-let (((> x 0)) (x (+ x 1))) (+ x 1)))))) + (let ((x 1)) (and-let* (((> x 0)) (x (+ x 1))) (+ x 1)))))) -(ert-deftest subr-x-and-let-test-rebind () +(ert-deftest subr-x-and-let*-test-rebind () (should (equal 4 (let ((x 1)) - (and-let (((> x 0)) (x (+ x 1)) (x (+ x 1))) (+ x 1)))))) + (and-let* (((> x 0)) (x (+ x 1)) (x (+ x 1))) (+ x 1)))))) -(ert-deftest subr-x-and-let-test-group-2 () +(ert-deftest subr-x-and-let*-test-group-2 () (should - (equal 2 (let ((x 1)) (and-let (x ((> x 0))) (+ x 1))))) + (equal 2 (let ((x 1)) (and-let* (x ((> x 0))) (+ x 1))))) (should - (equal 2 (let ((x 1)) (and-let (((progn x)) ((> x 0))) (+ x 1))))) - (should (equal nil (let ((x 0)) (and-let (x ((> x 0))) (+ x 1))))) - (should (equal nil (let ((x nil)) (and-let (x ((> x 0))) (+ x 1))))) + (equal 2 (let ((x 1)) (and-let* (((progn x)) ((> x 0))) (+ x 1))))) + (should (equal nil (let ((x 0)) (and-let* (x ((> x 0))) (+ x 1))))) + (should (equal nil (let ((x nil)) (and-let* (x ((> x 0))) (+ x 1))))) (should - (equal nil (let ((x nil)) (and-let (((progn x)) ((> x 0))) (+ x 1)))))) + (equal nil (let ((x nil)) (and-let* (((progn x)) ((> x 0))) (+ x 1)))))) -(ert-deftest subr-x-and-let-test-group-3 () +(ert-deftest subr-x-and-let*-test-group-3 () (should - (equal nil (let ((x 1)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) + (equal nil (let ((x 1)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) (should - (equal nil (let ((x 0)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) + (equal nil (let ((x 0)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) (should (equal nil - (let ((x nil)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y))))) + (let ((x nil)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y))))) (should (equal (/ 3.0 2) - (let ((x 3.0)) (and-let (x (y (- x 1)) ((> y 0))) (/ x y)))))) + (let ((x 3.0)) (and-let* (x (y (- x 1)) ((> y 0))) (/ x y)))))) From add48d206463255030a7cc958faa8efb63197836 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 6 Mar 2018 19:32:39 +0200 Subject: [PATCH 04/14] More minor changes in the Glossary of the Emacs manual * doc/emacs/glossary.texi (Glossary): Improve cross-references for modifier keys. Fix typos. Suggested by Gijs Hillenius in emacs-manual-bugs@gnu.org. --- doc/emacs/glossary.texi | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi index 148aafd1e51..6002e367cc9 100644 --- a/doc/emacs/glossary.texi +++ b/doc/emacs/glossary.texi @@ -720,10 +720,11 @@ customizing the various hooks, you can modify Emacs's behavior without changing any of its code. @xref{Hooks}. @item Hyper -Hyper is the name of a modifier bit that a keyboard input character may -have. To make a character Hyper, type it while holding down the +Hyper is the name of a modifier bit that a keyboard input character +may have. To make a character Hyper, type it while holding down the @key{Hyper} key. Such characters are given names that start with -@kbd{Hyper-} (usually written @kbd{H-} for short). @xref{User Input}. +@kbd{Hyper-} (usually written @kbd{H-} for short). @xref{Modifier +Keys}. @item i.e. Short for ``id est'' in Latin, which means ``that is''. @@ -1343,10 +1344,11 @@ which characters balance each other like parentheses, etc. Manual}. @item Super -Super is the name of a modifier bit that a keyboard input character may -have. To make a character Super, type it while holding down the +Super is the name of a modifier bit that a keyboard input character +may have. To make a character Super, type it while holding down the @key{SUPER} key. Such characters are given names that start with -@kbd{Super-} (usually written @kbd{s-} for short). @xref{User Input}. +@kbd{Super-} (usually written @kbd{s-} for short). @xref{Modifier +Keys}. @item Suspending Suspending Emacs means stopping it temporarily and returning control @@ -1493,13 +1495,13 @@ Emacs divides a frame (q.v.@:) into one or more windows, each of which can display the contents of one buffer (q.v.@:) at any time. @xref{Screen}, for basic information on how Emacs uses the screen. @xref{Windows}, for commands to control the use of windows. Some -other editors use the term ``window'' for what we call a ``frame'' -(q.v.@:) in Emacs. +other editors use the term ``window'' for what we call a ``frame'' in +Emacs. @item Window System A window system is software that operates on a graphical display -(q.v.), to subdivide the screen so that multiple applications can -have their] own windows at the same time. All modern operating systems +(q.v.), to subdivide the screen so that multiple applications can have +their own windows at the same time. All modern operating systems include a window system. @item Word Abbrev From 0efe0bd233de20bfb5bd9d06b255fc8ecf04602b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 6 Mar 2018 15:07:15 -0500 Subject: [PATCH 05/14] Obsolete eshell-cmpl-suffix-list * lisp/eshell/em-cmpl.el (eshell-cmpl-suffix-list): Make obsolete, to match pcomplete-suffix-list. --- lisp/eshell/em-cmpl.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 1f440077465..b56cf168a2b 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -167,6 +167,9 @@ to writing a completion function." (eshell-cmpl--custom-variable-docstring 'pcomplete-suffix-list) :type (get 'pcomplete-suffix-list 'custom-type) :group 'pcomplete) +;; Only labelled obsolete in 26.1, but all it does it set +;; pcomplete-suffix-list, which is itself obsolete since 24.1. +(make-obsolete-variable 'eshell-cmpl-suffix-list nil "24.1") (defcustom eshell-cmpl-recexact nil (eshell-cmpl--custom-variable-docstring 'pcomplete-recexact) From 19afff31c9340ba5c35504064fb0fadcc8a86aff Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 6 Mar 2018 20:13:51 -0500 Subject: [PATCH 06/14] Replace some obsolete aliases in documentation * doc/emacs/text.texi (Nroff Mode): * doc/misc/efaq.texi (How to add fonts): * lisp/gnus/nnheader.el (nnheader-insert-file-contents): * lisp/progmodes/pascal.el (pascal-outline-mode): Doc fixes re obsolete aliases. ; * src/frame.c (do_switch_frame): Comment. --- doc/emacs/text.texi | 16 ++++++++-------- doc/misc/efaq.texi | 2 +- lisp/gnus/nnheader.el | 2 +- lisp/progmodes/pascal.el | 2 +- src/frame.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index c8e36411a5c..b188c02a9ab 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -2057,27 +2057,27 @@ hook @code{text-mode-hook}, then @code{nroff-mode-hook} separators, pages are separated by @samp{.bp} commands, and comments start with backslash-doublequote. It also defines these commands: -@findex forward-text-line -@findex backward-text-line -@findex count-text-lines +@findex nroff-forward-text-line +@findex nroff-backward-text-line +@findex nroff-count-text-lines @kindex M-n @r{(Nroff mode)} @kindex M-p @r{(Nroff mode)} @kindex M-? @r{(Nroff mode)} @table @kbd @item M-n Move to the beginning of the next line that isn't an nroff command -(@code{forward-text-line}). An argument is a repeat count. +(@code{nroff-forward-text-line}). An argument is a repeat count. @item M-p -Like @kbd{M-n} but move up (@code{backward-text-line}). +Like @kbd{M-n} but move up (@code{nroff-backward-text-line}). @item M-? Displays in the echo area the number of text lines (lines that are not -nroff commands) in the region (@code{count-text-lines}). +nroff commands) in the region (@code{nroff-count-text-lines}). @end table -@findex electric-nroff-mode +@findex nroff-electric-mode Electric Nroff mode is a buffer-local minor mode that can be used with Nroff mode. To toggle this minor mode, type @kbd{M-x -electric-nroff-mode} (@pxref{Minor Modes}). When the mode is on, each +nroff-electric-mode} (@pxref{Minor Modes}). When the mode is on, each time you type @key{RET} to end a line containing an nroff command that opens a kind of grouping, the nroff command to close that grouping is automatically inserted on the following line. diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 6f4977779fd..e0dfc8936d9 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -4310,7 +4310,7 @@ fontset, or you can select it by setting the default font in your @file{~/.emacs}: @lisp - (set-default-font "fontset-bdf") + (set-frame-font "fontset-bdf") @end lisp diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el index 14bd14924ff..77afb09a2a8 100644 --- a/lisp/gnus/nnheader.el +++ b/lisp/gnus/nnheader.el @@ -945,7 +945,7 @@ first. Otherwise, find the newest one, though it may take a time." "Like `insert-file-contents', q.v., but only reads in the file. A buffer may be modified in several ways after reading into the buffer due to advanced Emacs features, such as file-name-handlers, format decoding, -find-file-hooks, etc. +find-file-hook, etc. This function ensures that none of these modifications will take place." (let ((coding-system-for-read nnheader-file-coding-system)) (mm-insert-file-contents filename visit beg end replace))) diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index 83f15d495b5..737dd9ea8a8 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el @@ -1425,7 +1425,7 @@ Pascal Outline mode provides some additional commands. \\[pascal-show-all]\t- Show the whole buffer. \\[pascal-hide-other-defuns]\ \t- Hide everything but the current function (function under the cursor). -\\[pascal-outline]\t- Leave Pascal Outline mode." +\\[pascal-outline-mode]\t- Leave Pascal Outline mode." :init-value nil :lighter " Outl" :keymap pascal-outline-map (add-to-invisibility-spec '(pascal . t)) (unless pascal-outline-mode diff --git a/src/frame.c b/src/frame.c index a86f05191a8..cee775c6fa9 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1419,7 +1419,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor /* We want to make sure that the next event generates a frame-switch event to the appropriate frame. This seems kludgy to me, but before you take it out, make sure that evaluating something like - (select-window (frame-root-window (new-frame))) doesn't end up + (select-window (frame-root-window (make-frame))) doesn't end up with your typing being interpreted in the new frame instead of the one you're actually typing in. */ #ifdef HAVE_WINDOW_SYSTEM From 501808ce690c93eac7df4b8f467ed940528d9229 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 6 Mar 2018 20:16:52 -0500 Subject: [PATCH 07/14] Replace some obsolete aliases in code * lisp/emulation/viper.el (viper-set-hooks): * lisp/epa-hook.el (auto-encryption-mode): * lisp/term/pc-win.el (set-frame-font): Replace obsolete aliases. * lisp/net/quickurl.el (quickurl--assoc-function): New. (quickurl-assoc-function): Use it. --- lisp/emulation/viper.el | 2 +- lisp/epa-hook.el | 2 +- lisp/net/quickurl.el | 7 ++++++- lisp/term/pc-win.el | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 13a88ad11fa..c8eca30e88b 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -902,7 +902,7 @@ Two differences: (viper-setup-ESC-to-escape t) (add-hook 'change-major-mode-hook #'viper-major-mode-change-sentinel) - (add-hook 'find-file-hooks #'set-viper-state-in-major-mode) + (add-hook 'find-file-hook #'set-viper-state-in-major-mode) ;; keep this because many modes we don't know about use this hook (defvar text-mode-hook) diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el index d99a3ef51a9..135c956c3f4 100644 --- a/lisp/epa-hook.el +++ b/lisp/epa-hook.el @@ -95,7 +95,7 @@ the mode if ARG is omitted or nil." :initialize 'custom-initialize-delay (setq file-name-handler-alist (delq epa-file-handler file-name-handler-alist)) - (remove-hook 'find-file-hooks 'epa-file-find-file-hook) + (remove-hook 'find-file-hook 'epa-file-find-file-hook) (setq auto-mode-alist (delq epa-file-auto-mode-alist-entry auto-mode-alist)) (when auto-encryption-mode diff --git a/lisp/net/quickurl.el b/lisp/net/quickurl.el index 5321807cd6c..abfca383e09 100644 --- a/lisp/net/quickurl.el +++ b/lisp/net/quickurl.el @@ -116,8 +116,13 @@ :type 'function :group 'quickurl) -(defcustom quickurl-assoc-function #'assoc-ignore-case +(defun quickurl--assoc-function (key alist) + "Default function for `quickurl-assoc-function'." + (assoc-string key alist t)) + +(defcustom quickurl-assoc-function #'quickurl--assoc-function "Function to use for alist lookup into `quickurl-urls'." + :version "26.1" ; was the obsolete assoc-ignore-case :type 'function :group 'quickurl) diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el index 83f5923ad59..62734d9cfe4 100644 --- a/lisp/term/pc-win.el +++ b/lisp/term/pc-win.el @@ -372,7 +372,7 @@ Consult the selection. Treat empty strings as if they were unset." (fset 'iconify-or-deiconify-frame 'ignore) ;; From lisp/frame.el -(fset 'set-default-font 'ignore) +(fset 'set-frame-font 'ignore) (fset 'set-mouse-color 'ignore) ; We cannot, I think. (fset 'set-cursor-color 'ignore) ; Hardware determined by char under. (fset 'set-border-color 'ignore) ; Not useful. From d523e4accd6656b6960e0990a353f00b1f42feff Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 6 Mar 2018 20:18:54 -0500 Subject: [PATCH 08/14] Remove some unused spam.el variables * lisp/gnus/spam.el (spam-ifile-path, spam-ifile-database-path) (spam-bogofilter-path, spam-bsfilter-path) (spam-spamassassin-path, spam-sa-learn-path): Remove variables that are described as obsolete, but are really completely unused, and have been for years. --- lisp/gnus/spam.el | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el index f2024a339b0..1c2b3467237 100644 --- a/lisp/gnus/spam.el +++ b/lisp/gnus/spam.el @@ -411,16 +411,12 @@ Only meaningful if you enable `spam-use-regex-body'." "Spam ifile configuration." :group 'spam) -(make-obsolete-variable 'spam-ifile-path 'spam-ifile-program - "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-ifile-program (executable-find "ifile") "Name of the ifile program." :type '(choice (file :tag "Location of ifile") (const :tag "ifile is not installed")) :group 'spam-ifile) -(make-obsolete-variable 'spam-ifile-database-path 'spam-ifile-database - "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-ifile-database nil "File name of the ifile database." :type '(choice (file :tag "Location of the ifile database") @@ -450,8 +446,6 @@ your main source of newsgroup names." "Spam bogofilter configuration." :group 'spam) -(make-obsolete-variable 'spam-bogofilter-path 'spam-bogofilter-program - "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-bogofilter-program (executable-find "bogofilter") "Name of the Bogofilter program." :type '(choice (file :tag "Location of bogofilter") @@ -502,8 +496,6 @@ When nil, use the default location." "Spam bsfilter configuration." :group 'spam) -(make-obsolete-variable 'spam-bsfilter-path 'spam-bsfilter-program - "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-bsfilter-program (executable-find "bsfilter") "Name of the Bsfilter program." :type '(choice (file :tag "Location of bsfilter") @@ -568,8 +560,6 @@ When nil, use the default spamoracle database." "Spam SpamAssassin configuration." :group 'spam) -(make-obsolete-variable 'spam-spamassassin-path - 'spam-spamassassin-program "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-assassin-program (executable-find "spamassassin") "Name of the spamassassin program. Hint: set this to \"spamc\" if you have spamd running. See the spamc and @@ -600,8 +590,6 @@ identification" :type 'string :group 'spam-spamassassin) -(make-obsolete-variable 'spam-sa-learn-path 'spam-sa-learn-program - "Gnus 5.10.9 (Emacs 22.1)") (defcustom spam-sa-learn-program (executable-find "sa-learn") "Name of the sa-learn program." :type '(choice (file :tag "Location of spamassassin") From 61c1f80f0544b3da784f97ec2368aec809c8524b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 7 Mar 2018 21:02:24 +0200 Subject: [PATCH 09/14] Minor copyedits in display.texi * doc/emacs/display.texi (Highlight Interactively) (Useless Whitespace, Line Truncation, Visual Line Mode): Minor changes of wording and typo corrections. Suggested by Michael Albinus in emacs-manual-bugs@gnu.org. --- doc/emacs/display.texi | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 312f70e13ba..3a0116a7456 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -971,7 +971,7 @@ version.) Highlight text that matches @var{regexp} using face @var{face} (@code{highlight-regexp}). The highlighting will remain as long as the buffer is loaded. For example, to highlight all occurrences of -the word ``whim'' using the default face (a yellow background) +the word ``whim'' using the default face (a yellow background), type @kbd{M-s h r whim @key{RET} @key{RET}}. Any face can be used for highlighting, Hi Lock provides several of its own and these are pre-loaded into a list of default values. While being prompted @@ -1239,7 +1239,7 @@ and @code{newline-mark}. Highlight trailing whitespace. @item tabs -Highlight tab characters. +Highlight TAB characters. @item spaces Highlight space and non-breaking space characters. @@ -1263,10 +1263,10 @@ highlighted. To change that, customize the regular expression @code{whitespace-big-indent-regexp}. @item space-mark -Draw space and non-breaking characters with a special glyph. +Draw SPC and non-breaking characters with a special glyph. @item tab-mark -Draw tab characters with a special glyph. +Draw TAB characters with a special glyph. @item newline-mark Draw newline characters with a special glyph. @@ -1649,8 +1649,8 @@ Emacs can display long lines by @dfn{truncation}. This means that all the characters that do not fit in the width of the screen or window do not appear at all. On graphical displays, a small straight arrow in the fringe indicates truncation at either end of the line. On text -terminals, this is indicated with @samp{$} signs in the leftmost -and/or rightmost columns. +terminals, this is indicated with @samp{$} signs in the rightmost +and/or leftmost columns. @vindex truncate-lines @findex toggle-truncate-lines @@ -1676,8 +1676,9 @@ line truncation. @xref{Split Window}, for the variable @dfn{word wrap}. Here, each long logical line is divided into two or more screen lines, like in ordinary line continuation. However, Emacs attempts to wrap the line at word boundaries near the right window -edge. This makes the text easier to read, as wrapping does not occur -in the middle of words. +edge. (If line's direction is right-to-left, it is wrapped at the +left window edge instead.) This makes the text easier to read, as +wrapping does not occur in the middle of words. @cindex mode, Visual Line @cindex Visual Line mode @@ -1688,8 +1689,8 @@ To turn on Visual Line mode in the current buffer, type @kbd{M-x visual-line-mode}; repeating this command turns it off. You can also turn on Visual Line mode using the menu bar: in the Options menu, select the @samp{Line Wrapping in this Buffer} submenu, followed by -the @samp{Word Wrap (Visual Line Mode)} menu item. While Visual Line -mode is enabled, the mode-line shows the string @samp{wrap} in the +the @samp{Word Wrap (Visual Line mode)} menu item. While Visual Line +mode is enabled, the mode line shows the string @samp{wrap} in the mode display. The command @kbd{M-x global-visual-line-mode} toggles Visual Line mode in all buffers. From 317da2ace54e971c788d4718874df957d3d1c549 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 7 Mar 2018 21:51:59 +0200 Subject: [PATCH 10/14] Minor improvements in manuals * doc/lispref/variables.texi (Local Variables): Make more clear that local bindings of 'let' are in effect only within the body. Suggested by Marcin Borkowski , see http://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00217.html for the details. * doc/emacs/programs.texi (Matching): Fix a typo. Reported by Alex Branham in emacs-manual-bugs@gnu.org. Improve indexing. --- doc/emacs/programs.texi | 6 +++++- doc/lispref/variables.texi | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index c34b55fc00e..d3d7028c149 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -849,11 +849,13 @@ options which control the operation of this mode include: @itemize @bullet @item -@code{show-paren-highlight-open-paren} controls whether to highlight +@vindex show-paren-highlight-openparen +@code{show-paren-highlight-openparen} controls whether to highlight an open paren when point stands just before it, and hence its position is marked by the cursor anyway. The default is non-@code{nil} (yes). @item +@vindex show-paren-style @code{show-paren-style} controls whether just the two parens, or also the space between them get highlighted. The valid options here are @code{parenthesis} (show the matching paren), @code{expression} @@ -862,10 +864,12 @@ the space between them get highlighted. The valid options here are expression otherwise). @item +@vindex show-paren-when-point-inside-paren @code{show-paren-when-point-inside-paren}, when non-@code{nil}, causes highlighting also when point is on the inside of a parenthesis. @item +@vindex show-paren-when-point-in-periphery @code{show-paren-when-point-in-periphery}, when non-@code{nil}, causes highlighting also when point is in whitespace at the beginning or end of a line, and there is a paren at, respectively, the first or last, diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index e025d3fd10b..aecee6f3056 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -165,7 +165,7 @@ receive local values, which are the actual arguments supplied to the function call; these local bindings take effect within the body of the function. To take another example, the @code{let} special form explicitly establishes local bindings for specific variables, which -take effect within the body of the @code{let} form. +take effect only within the body of the @code{let} form. We also speak of the @dfn{global binding}, which is where (conceptually) the global value is kept. @@ -204,7 +204,8 @@ bindings: This special form sets up local bindings for a certain set of variables, as specified by @var{bindings}, and then evaluates all of the @var{forms} in textual order. Its return value is the value of -the last form in @var{forms}. +the last form in @var{forms}. The local bindings set up by @code{let} +will be in effect only within the body of @var{forms}. Each of the @var{bindings} is either @w{(i) a} symbol, in which case that symbol is locally bound to @code{nil}; or @w{(ii) a} list of the From 6bcb48cf274fb1dd290b305e0ef01fbc1dbbaf66 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 7 Mar 2018 15:41:29 -0500 Subject: [PATCH 11/14] Replace some obsolete aliases in documentation * doc/misc/efaq-w32.texi (Incoming mail with Rmail): * doc/misc/speedbar.texi (Major Display Modes): * lisp/mh-e/mh-folder.el (mh-restore-desktop-buffer): Doc fixes re obsolete aliases. ; * lisp/autoinsert.el (auto-insert): ; * lisp/ffap.el (ffap-newfile-prompt): ; * lisp/woman.el (woman-insert-file-contents): Comment fixes. --- doc/misc/efaq-w32.texi | 4 ++-- doc/misc/speedbar.texi | 8 ++++---- lisp/autoinsert.el | 2 +- lisp/ffap.el | 2 +- lisp/mh-e/mh-folder.el | 2 +- lisp/woman.el | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/misc/efaq-w32.texi b/doc/misc/efaq-w32.texi index af002d7a28f..8cdf870ad64 100644 --- a/doc/misc/efaq-w32.texi +++ b/doc/misc/efaq-w32.texi @@ -1595,7 +1595,7 @@ non-@code{nil}, you should set it to @code{nil}: @cindex movemail, using pop3 @cindex MAILHOST @vindex rmail-primary-inbox-list -@vindex rmail-pop-password-required +@vindex rmail-remote-password-required For incoming mail using the Rmail package and a POP3 server, you will need the following configuration: @@ -1603,7 +1603,7 @@ need the following configuration: @example (setenv "MAILHOST" "@var{domain.name.of.your.pop3.server}") (setq rmail-primary-inbox-list '("po:@var{your logon id}")) -(setq rmail-pop-password-required t) +(setq rmail-remote-password-required t) @end example @node Incoming mail with Gnus diff --git a/doc/misc/speedbar.texi b/doc/misc/speedbar.texi index 1c1b014f54e..d67c4e61456 100644 --- a/doc/misc/speedbar.texi +++ b/doc/misc/speedbar.texi @@ -979,8 +979,8 @@ With a numeric argument (@kbd{C-u}), flush cached data before expanding. Contract the item under the cursor. @end table -@cindex @code{speedbar-line-path} -These function require that function @code{speedbar-line-path} be +@cindex @code{speedbar-line-directory} +These functions require that the function @code{speedbar-line-directory} be correctly overloaded to work. Next, register your extension like this; @@ -1013,14 +1013,14 @@ like this: (speedbar-add-mode-functions-list '("MYEXTENSION" (speedbar-item-info . MyExtension-speedbar-item-info) - (speedbar-line-path . MyExtension-speedbar-line-path))) + (speedbar-line-directory . MyExtension-speedbar-line-directory))) @end example The first element in the list is the name of you extension. The second is an alist of functions to overload. The function to overload is first, followed by what you want called instead. -For @code{speedbar-line-path} your function should take an optional DEPTH +For @code{speedbar-line-directory} your function should take an optional DEPTH parameter. This is the starting depth for heavily indented lines. If it is not provided, you can derive it like this: diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index f2ca52b1a19..dfa5b603068 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el @@ -386,7 +386,7 @@ Matches the visited file name against the elements of `auto-insert-alist'." (not (eq this-command 'auto-insert)) (set-buffer-modified-p (eq auto-insert t))))) ;; Return nil so that it could be used in - ;; `find-file-not-found-hooks', though that's probably inadvisable. + ;; `find-file-not-found-functions', though that's probably inadvisable. nil) diff --git a/lisp/ffap.el b/lisp/ffap.el index 4e479d1b82b..22be2f85369 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -248,7 +248,7 @@ it passes it on to `dired'." (defcustom ffap-newfile-prompt nil ;; Suggestion from RHOGEE, 11 Jul 1994. Disabled, I think this is - ;; better handled by `find-file-not-found-hooks'. + ;; better handled by `find-file-not-found-functions'. "Whether `find-file-at-point' prompts about a nonexistent file." :type 'boolean :group 'ffap) diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el index 23cc2baab79..82e28e8741d 100644 --- a/lisp/mh-e/mh-folder.el +++ b/lisp/mh-e/mh-folder.el @@ -88,7 +88,7 @@ the MH mail system." When desktop creates a buffer, DESKTOP-BUFFER-FILE-NAME holds the file name to visit, DESKTOP-BUFFER-NAME holds the desired buffer name, and DESKTOP-BUFFER-MISC holds a list of miscellaneous info -used by the `desktop-buffer-handlers' functions." +used by the `desktop-buffer-mode-handlers' functions." (mh-find-path) (mh-visit-folder desktop-buffer-name) (current-buffer)) diff --git a/lisp/woman.el b/lisp/woman.el index 73f18b0dd6a..533f14674ab 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -1759,8 +1759,8 @@ Leave point at end of new text. Return length of inserted text." (condition-case () (insert-file-contents filename nil) (file-error - ;; Run find-file-not-found-hooks until one returns non-nil. - ;; (run-hook-with-args-until-success 'find-file-not-found-hooks) + ;; Run find-file-not-found-functions until one returns non-nil. + ;; (run-hook-with-args-until-success 'find-file-not-found-functions) (insert "\n***** File " filename " not found! *****\n\n"))))))) From 685175404f04b56daeb5c706333e35f671e60e82 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 7 Mar 2018 15:44:08 -0500 Subject: [PATCH 12/14] Replace some obsolete aliases in code * lisp/net/eudc-bob.el (eudc-bob-mail-keymap): * lisp/textmodes/reftex-toc.el (reftex-make-separate-toc-frame): Replace obsolete aliases. --- lisp/net/eudc-bob.el | 2 +- lisp/textmodes/reftex-toc.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/net/eudc-bob.el b/lisp/net/eudc-bob.el index 57b748b1500..584d1a9d0d8 100644 --- a/lisp/net/eudc-bob.el +++ b/lisp/net/eudc-bob.el @@ -312,7 +312,7 @@ display a button." (define-key map [return] 'goto-address-at-point) (define-key map (if (featurep 'xemacs) [button2] - [down-mouse-2]) 'goto-address-at-mouse) + [down-mouse-2]) 'goto-address-at-point) map)) (set-keymap-parent eudc-bob-image-keymap eudc-bob-generic-keymap) diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el index 6637da4b144..9c158a5f569 100644 --- a/lisp/textmodes/reftex-toc.el +++ b/lisp/textmodes/reftex-toc.el @@ -1096,7 +1096,7 @@ always show the current section in connection with the option (when (eq reftex-auto-recenter-toc 'frame) (unless reftex-toc-auto-recenter-timer (reftex-toggle-auto-toc-recenter)) - (add-hook 'delete-frame-hook 'reftex-toc-delete-frame-hook))))) + (add-hook 'delete-frame-functions 'reftex-toc-delete-frame-hook))))) (defun reftex-toc-delete-frame-hook (frame) (if (and reftex-toc-auto-recenter-timer From 7e26d8356aad20d62b54a6fd649ba577ae9a48a8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 8 Mar 2018 17:53:09 +0200 Subject: [PATCH 13/14] More minor changes in the manual * doc/emacs/display.texi (Useless Whitespace): Don't upcase "TAB" and "SPC" when alluding to characters. Suggested by Richard Stallman . * doc/emacs/buffers.texi (Misc Buffer): Clarify what "read-only" means for buffers. (Buffers): Define and describe "buffer contents". Suggested by Richard Stallman . (Bug#30685) --- doc/emacs/buffers.texi | 22 +++++++++++++++------- doc/emacs/display.texi | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi index f8c1856058a..dd7a653186c 100644 --- a/doc/emacs/buffers.texi +++ b/doc/emacs/buffers.texi @@ -32,6 +32,13 @@ buffer. When there is only one Emacs window, the buffer displayed in that window is current. When there are multiple windows, the buffer displayed in the @dfn{selected window} is current. @xref{Windows}. +@cindex buffer contents +@cindex contents of a buffer + A buffer's @dfn{contents} consist of a series of characters, each of +which optionally carries a set of text properties +(@pxref{International Chars, Text properties}) that can specify more +information about that character. + Aside from its textual contents, each buffer records several pieces of information, such as what file it is visiting (if any), whether it is modified, and what major mode and minor modes are in effect @@ -231,13 +238,14 @@ Scroll through buffer @var{buffer}. @xref{View Mode}. @kindex C-x C-q @vindex buffer-read-only @cindex read-only buffer - A buffer can be @dfn{read-only}, which means that commands to change -its contents are not allowed. The mode line indicates read-only -buffers with @samp{%%} or @samp{%*} near the left margin. @xref{Mode -Line}. Read-only buffers are usually made by subsystems such as Dired -and Rmail that have special commands to operate on the text. Visiting -a file whose access control says you cannot write it also makes the -buffer read-only. + A buffer can be @dfn{read-only}, which means that commands to insert +or delete its text are not allowed. (However, other commands, like +@kbd{C-x @key{RET} f}, can still mark it as modified, @pxref{Text +Coding}). The mode line indicates read-only buffers with @samp{%%} or +@samp{%*} near the left margin. @xref{Mode Line}. Read-only buffers +are usually made by subsystems such as Dired and Rmail that have +special commands to operate on the text. Visiting a file whose access +control says you cannot write it also makes the buffer read-only. @findex read-only-mode @vindex view-read-only diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 3a0116a7456..ad3221463a4 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -1258,7 +1258,7 @@ Highlight empty lines. @item big-indent @vindex whitespace-big-indent-regexp Highlight too-deep indentation. By default any sequence of at least 4 -consecutive TAB characters or 32 consecutive SPC characters is +consecutive tab characters or 32 consecutive space characters is highlighted. To change that, customize the regular expression @code{whitespace-big-indent-regexp}. @@ -1266,7 +1266,7 @@ highlighted. To change that, customize the regular expression Draw SPC and non-breaking characters with a special glyph. @item tab-mark -Draw TAB characters with a special glyph. +Draw tab characters with a special glyph. @item newline-mark Draw newline characters with a special glyph. From cb0d40eab406e7df22b09f7ae5557c820c087af4 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 8 Mar 2018 17:08:47 +0100 Subject: [PATCH 14/14] Minor change in the manual * doc/emacs/display.texi (Useless Whitespace): Don't upcase "TAB" and "SPC" when alluding to characters. --- doc/emacs/display.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index ad3221463a4..499be26004d 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -1239,7 +1239,7 @@ and @code{newline-mark}. Highlight trailing whitespace. @item tabs -Highlight TAB characters. +Highlight tab characters. @item spaces Highlight space and non-breaking space characters. @@ -1263,7 +1263,7 @@ highlighted. To change that, customize the regular expression @code{whitespace-big-indent-regexp}. @item space-mark -Draw SPC and non-breaking characters with a special glyph. +Draw space and non-breaking characters with a special glyph. @item tab-mark Draw tab characters with a special glyph.