1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-14 16:50:58 +00:00

Change how thread-first/thread-last indent the first argument

* lisp/doc-view.el (doc-view--current-cache-dir): Reindent.

* lisp/emacs-lisp/subr-x.el (thread-first):
(thread-last): Change indentation to match examples.
(internal--build-binding): Reindent.

* test/lisp/emacs-lisp/subr-x-tests.el
(subr-x-test-thread-first-function-names-are-threaded):
(subr-x-test-thread-first-examples):
(subr-x-test-thread-last-function-names-are-threaded):
(subr-x-test-thread-last-examples): Reindent.
This commit is contained in:
Lars Ingebrigtsen 2021-09-22 05:57:48 +02:00
parent 8a8319140c
commit 2a73673809
3 changed files with 14 additions and 14 deletions

View File

@ -727,7 +727,7 @@ It's a subdirectory of `doc-view-cache-directory'."
(file-name-as-directory (file-name-as-directory
(expand-file-name (expand-file-name
(concat (thread-last (concat (thread-last
(file-name-nondirectory doc-view--buffer-file-name) (file-name-nondirectory doc-view--buffer-file-name)
;; bug#13679 ;; bug#13679
(subst-char-in-string ?% ?_) (subst-char-in-string ?% ?_)
;; arc-mode concatenates archive name and file name ;; arc-mode concatenates archive name and file name

View File

@ -62,7 +62,7 @@ Is equivalent to:
(+ (- (/ (+ 5 20) 25)) 40) (+ (- (/ (+ 5 20) 25)) 40)
Note how the single `-' got converted into a list before Note how the single `-' got converted into a list before
threading." threading."
(declare (indent 1) (declare (indent 0)
(debug (form &rest [&or symbolp (sexp &rest form)]))) (debug (form &rest [&or symbolp (sexp &rest form)])))
`(internal--thread-argument t ,@forms)) `(internal--thread-argument t ,@forms))
@ -79,7 +79,7 @@ Is equivalent to:
(+ 40 (- (/ 25 (+ 20 5)))) (+ 40 (- (/ 25 (+ 20 5))))
Note how the single `-' got converted into a list before Note how the single `-' got converted into a list before
threading." threading."
(declare (indent 1) (debug thread-first)) (declare (indent 0) (debug thread-first))
`(internal--thread-argument nil ,@forms)) `(internal--thread-argument nil ,@forms))
(defsubst internal--listify (elt) (defsubst internal--listify (elt)
@ -107,7 +107,7 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
(defun internal--build-binding (binding prev-var) (defun internal--build-binding (binding prev-var)
"Check and build a single BINDING with PREV-VAR." "Check and build a single BINDING with PREV-VAR."
(thread-first (thread-first
binding binding
internal--listify internal--listify
internal--check-binding internal--check-binding
(internal--build-binding-value-form prev-var))) (internal--build-binding-value-form prev-var)))

View File

@ -455,18 +455,18 @@
"Test `thread-first' wraps single function names." "Test `thread-first' wraps single function names."
(should (equal (macroexpand (should (equal (macroexpand
'(thread-first 5 '(thread-first 5
-)) -))
'(- 5))) '(- 5)))
(should (equal (macroexpand (should (equal (macroexpand
'(thread-first (+ 1 2) '(thread-first (+ 1 2)
-)) -))
'(- (+ 1 2))))) '(- (+ 1 2)))))
(ert-deftest subr-x-test-thread-first-expansion () (ert-deftest subr-x-test-thread-first-expansion ()
"Test `thread-first' expands correctly." "Test `thread-first' expands correctly."
(should (equal (should (equal
(macroexpand '(thread-first (macroexpand '(thread-first
5 5
(+ 20) (+ 20)
(/ 25) (/ 25)
- -
@ -477,13 +477,13 @@
"Test several `thread-first' examples." "Test several `thread-first' examples."
(should (equal (thread-first (+ 40 2)) 42)) (should (equal (thread-first (+ 40 2)) 42))
(should (equal (thread-first (should (equal (thread-first
5 5
(+ 20) (+ 20)
(/ 25) (/ 25)
- -
(+ 40)) 39)) (+ 40)) 39))
(should (equal (thread-first (should (equal (thread-first
"this-is-a-string" "this-is-a-string"
(split-string "-") (split-string "-")
(nbutlast 2) (nbutlast 2)
(append (list "good"))) (append (list "good")))
@ -500,18 +500,18 @@
"Test `thread-last' wraps single function names." "Test `thread-last' wraps single function names."
(should (equal (macroexpand (should (equal (macroexpand
'(thread-last 5 '(thread-last 5
-)) -))
'(- 5))) '(- 5)))
(should (equal (macroexpand (should (equal (macroexpand
'(thread-last (+ 1 2) '(thread-last (+ 1 2)
-)) -))
'(- (+ 1 2))))) '(- (+ 1 2)))))
(ert-deftest subr-x-test-thread-last-expansion () (ert-deftest subr-x-test-thread-last-expansion ()
"Test `thread-last' expands correctly." "Test `thread-last' expands correctly."
(should (equal (should (equal
(macroexpand '(thread-last (macroexpand '(thread-last
5 5
(+ 20) (+ 20)
(/ 25) (/ 25)
- -
@ -522,13 +522,13 @@
"Test several `thread-last' examples." "Test several `thread-last' examples."
(should (equal (thread-last (+ 40 2)) 42)) (should (equal (thread-last (+ 40 2)) 42))
(should (equal (thread-last (should (equal (thread-last
5 5
(+ 20) (+ 20)
(/ 25) (/ 25)
- -
(+ 40)) 39)) (+ 40)) 39))
(should (equal (thread-last (should (equal (thread-last
(list 1 -2 3 -4 5) (list 1 -2 3 -4 5)
(mapcar #'abs) (mapcar #'abs)
(cl-reduce #'+) (cl-reduce #'+)
(format "abs sum is: %s")) (format "abs sum is: %s"))