Tidy: Indentation of dash forms

See, e.g. <https://github.com/magnars/dash.el/pull/375>.

Ultimately I'd prefer to indent with one distinguished argument, but
the noise it causes downstream is likely not worth it.  (And,
unfortunately, the indentation of the built-in thread-first and
thread-last forms has changed to be like this as well, which is even
worse, causing 10-11 characters of extra indentation in those forms'
bodies!)
This commit is contained in:
Adam Porter 2023-03-09 00:01:32 -06:00
parent 29533525c3
commit a5fbb5d976
5 changed files with 84 additions and 84 deletions

View file

@ -59,8 +59,8 @@ Based on `helm-map'.")
(helm-make-source "Org QL Views" 'helm-source-sync (helm-make-source "Org QL Views" 'helm-source-sync
:candidates (lambda () :candidates (lambda ()
(->> org-ql-views (->> org-ql-views
(-map #'car) (-map #'car)
(-sort #'string<))) (-sort #'string<)))
:action (list (cons "Show view" #'org-ql-view))) :action (list (cons "Show view" #'org-ql-view)))
"Helm source for `org-ql-views'.") "Helm source for `org-ql-views'.")
@ -209,8 +209,8 @@ WINDOW-WIDTH should be the width of the Helm window."
(width (- window-width (length prefix))) (width (- window-width (length prefix)))
(heading (org-get-heading t)) (heading (org-get-heading t))
(path (-> (org-get-outline-path) (path (-> (org-get-outline-path)
(org-format-outline-path width nil "") (org-format-outline-path width nil "")
(org-split-string ""))) (org-split-string "")))
(path (if helm-org-ql-reverse-paths (path (if helm-org-ql-reverse-paths
(concat heading "\\" (s-join "\\" (nreverse path))) (concat heading "\\" (s-join "\\" (nreverse path)))
(concat (s-join "/" path) "/" heading)))) (concat (s-join "/" path) "/" heading))))

View file

@ -233,9 +233,9 @@ automatically from the query."
;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing. ;; `org-agenda-multi' is bound non-nil, in which case `org-agenda-finalize' does nothing.
;; But we do call `org-agenda-finalize-entries', which allows `org-super-agenda' to work. ;; But we do call `org-agenda-finalize-entries', which allows `org-super-agenda' to work.
(->> items (->> items
(-map #'org-ql-view--format-element) (-map #'org-ql-view--format-element)
org-agenda-finalize-entries org-agenda-finalize-entries
insert) insert)
(insert "\n")))) (insert "\n"))))
;;;###autoload ;;;###autoload
@ -355,8 +355,8 @@ For example, an org-ql dynamic block header could look like:
When RECURSE is non-nil, recurse into subdirectories. When When RECURSE is non-nil, recurse into subdirectories. When
REGEXP is non-nil, only return files that match REGEXP." REGEXP is non-nil, only return files that match REGEXP."
(let ((files (->> directories (let ((files (->> directories
(--map (f-files it nil recurse)) (--map (f-files it nil recurse))
-flatten))) -flatten)))
(if regexp (if regexp
(--select (string-match regexp it) (--select (string-match regexp it)
files) files)

View file

@ -153,11 +153,11 @@ See info node `(elisp)Cyclic Window Ordering'."
(interactive) (interactive)
(let* ((ts (ts-now)) (let* ((ts (ts-now))
(beg-of-week (->> ts (beg-of-week (->> ts
(ts-adjust 'day (- (ts-dow (ts-now)))) (ts-adjust 'day (- (ts-dow (ts-now))))
(ts-apply :hour 0 :minute 0 :second 0))) (ts-apply :hour 0 :minute 0 :second 0)))
(end-of-week (->> ts (end-of-week (->> ts
(ts-adjust 'day (- 6 (ts-dow (ts-now)))) (ts-adjust 'day (- 6 (ts-dow (ts-now))))
(ts-apply :hour 23 :minute 59 :second 59)))) (ts-apply :hour 23 :minute 59 :second 59))))
(org-ql-search (org-agenda-files) (org-ql-search (org-agenda-files)
`(ts-active :from ,beg-of-week `(ts-active :from ,beg-of-week
:to ,end-of-week) :to ,end-of-week)
@ -170,11 +170,11 @@ See info node `(elisp)Cyclic Window Ordering'."
(interactive) (interactive)
(let* ((ts (ts-adjust 'day 7 (ts-now))) (let* ((ts (ts-adjust 'day 7 (ts-now)))
(beg-of-week (->> ts (beg-of-week (->> ts
(ts-adjust 'day (- (ts-dow (ts-now)))) (ts-adjust 'day (- (ts-dow (ts-now))))
(ts-apply :hour 0 :minute 0 :second 0))) (ts-apply :hour 0 :minute 0 :second 0)))
(end-of-week (->> ts (end-of-week (->> ts
(ts-adjust 'day (- 6 (ts-dow (ts-now)))) (ts-adjust 'day (- 6 (ts-dow (ts-now))))
(ts-apply :hour 23 :minute 59 :second 59)))) (ts-apply :hour 23 :minute 59 :second 59))))
(org-ql-search (org-agenda-files) (org-ql-search (org-agenda-files)
`(ts-active :from ,beg-of-week `(ts-active :from ,beg-of-week
:to ,end-of-week) :to ,end-of-week)
@ -272,8 +272,8 @@ TYPE may be `ts', `ts-active', `ts-inactive', `clocked', or
`closed'." `closed'."
(interactive (list :num-days (read-number "Days: ") (interactive (list :num-days (read-number "Days: ")
:type (->> '(ts ts-active ts-inactive clocked closed) :type (->> '(ts ts-active ts-inactive clocked closed)
(completing-read "Timestamp type: ") (completing-read "Timestamp type: ")
intern))) intern)))
;; It doesn't make much sense to use other date-based selectors to ;; It doesn't make much sense to use other date-based selectors to
;; look into the past, so to prevent confusion, we won't allow them. ;; look into the past, so to prevent confusion, we won't allow them.
(-let* ((query (pcase-exhaustive type (-let* ((query (pcase-exhaustive type
@ -395,12 +395,12 @@ update search arguments."
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
(->> org-ql-views (->> org-ql-views
(-map #'car) (-map #'car)
(-sort (if org-ql-view-sidebar-sort-views (-sort (if org-ql-view-sidebar-sort-views
#'string< #'string<
#'ignore)) #'ignore))
(s-join "\n") (s-join "\n")
insert)) insert))
(current-buffer))) (current-buffer)))
(defvar bookmark-make-record-function) (defvar bookmark-make-record-function)
@ -469,8 +469,8 @@ If TITLE, prepend it to the header."
(format "%s" (org-ql-view--contract-buffers-files buffers-files)))) (format "%s" (org-ql-view--contract-buffers-files buffers-files))))
(buffers-files-formatted (when buffers-files-formatted (buffers-files-formatted (when buffers-files-formatted
(propertize (->> buffers-files-formatted (propertize (->> buffers-files-formatted
(org-ql-view--font-lock-string 'emacs-lisp-mode) (org-ql-view--font-lock-string 'emacs-lisp-mode)
(s-truncate available-width)) (s-truncate available-width))
'help-echo buffers-files-formatted)))) 'help-echo buffers-files-formatted))))
(concat title (concat title
(when query (propertize "Query:" 'face 'transient-argument)) (when query (propertize "Query:" 'face 'transient-argument))
@ -750,8 +750,8 @@ When opened, the link searches the buffer it's opened from."
(s-truncate (- (window-width) 15) (s-truncate (- (window-width) 15)
(concat (propertize key 'face 'transient-argument) ": " (concat (propertize key 'face 'transient-argument) ": "
(->> value (->> value
org-ql-view--format-query org-ql-view--format-query
(org-ql-view--font-lock-string 'emacs-lisp-mode))))) (org-ql-view--font-lock-string 'emacs-lisp-mode)))))
(transient-define-infix org-ql-view--transient-title () (transient-define-infix org-ql-view--transient-title ()
;; TODO: Add an asterisk or something when the view has been modified but not saved. ;; TODO: Add an asterisk or something when the view has been modified but not saved.
@ -850,8 +850,8 @@ return an empty string."
;; Adding the relative due date property should probably be done explicitly and separately ;; Adding the relative due date property should probably be done explicitly and separately
;; (which would also make it easier to do it independently of faces, etc). ;; (which would also make it easier to do it independently of faces, etc).
(title (--> (org-ql-view--add-faces element) (title (--> (org-ql-view--add-faces element)
(org-element-property :raw-value it) (org-element-property :raw-value it)
(org-link-display-format it))) (org-link-display-format it)))
(todo-keyword (-some--> (org-element-property :todo-keyword element) (todo-keyword (-some--> (org-element-property :todo-keyword element)
(org-ql-view--add-todo-face it))) (org-ql-view--add-todo-face it)))
(tag-list (if org-use-tag-inheritance (tag-list (if org-use-tag-inheritance
@ -872,9 +872,9 @@ return an empty string."
(org-element-property :tags element))) (org-element-property :tags element)))
(tag-string (when tag-list (tag-string (when tag-list
(--> tag-list (--> tag-list
(s-join ":" it) (s-join ":" it)
(s-wrap it ":") (s-wrap it ":")
(org-add-props it nil 'face 'org-tag)))) (org-add-props it nil 'face 'org-tag))))
;; (category (org-element-property :category element)) ;; (category (org-element-property :category element))
(priority-string (-some->> (org-element-property :priority element) (priority-string (-some->> (org-element-property :priority element)
(char-to-string) (char-to-string)
@ -890,19 +890,19 @@ return an empty string."
(remove-list-of-text-properties 0 (length string) '(line-prefix) string) (remove-list-of-text-properties 0 (length string) '(line-prefix) string)
;; Add all the necessary properties and faces to the whole string ;; Add all the necessary properties and faces to the whole string
(--> string (--> string
;; FIXME: Use proper prefix ;; FIXME: Use proper prefix
(concat " " it) (concat " " it)
(org-add-props it properties (org-add-props it properties
'org-agenda-type 'search 'org-agenda-type 'search
'todo-state todo-keyword 'todo-state todo-keyword
'tags tag-list 'tags tag-list
'org-habit-p habit-property))))) 'org-habit-p habit-property)))))
(defun org-ql-view--add-faces (element) (defun org-ql-view--add-faces (element)
"Return ELEMENT with deadline and scheduled faces added." "Return ELEMENT with deadline and scheduled faces added."
(->> element (->> element
(org-ql-view--add-scheduled-face) (org-ql-view--add-scheduled-face)
(org-ql-view--add-deadline-face))) (org-ql-view--add-deadline-face)))
(defun org-ql-view--add-priority-face (string) (defun org-ql-view--add-priority-face (string)
"Return STRING with priority face added." "Return STRING with priority face added."
@ -959,11 +959,11 @@ return an empty string."
((> today-day-number scheduled-day-number) 'org-scheduled-previously) ((> today-day-number scheduled-day-number) 'org-scheduled-previously)
(t 'org-scheduled))) (t 'org-scheduled)))
(title (--> (org-element-property :raw-value element) (title (--> (org-element-property :raw-value element)
(org-add-props it nil (org-add-props it nil
'face face))) 'face face)))
(properties (--> (cadr element) (properties (--> (cadr element)
(plist-put it :title title) (plist-put it :title title)
(plist-put it :relative-due-date relative-due-date)))) (plist-put it :relative-due-date relative-due-date))))
(list (car element) (list (car element)
properties)) properties))
;; Not scheduled ;; Not scheduled
@ -985,16 +985,16 @@ property."
;; FIXME: Unused for now: (done-p (member todo-keyword org-done-keywords)) ;; FIXME: Unused for now: (done-p (member todo-keyword org-done-keywords))
;; FIXME: Unused for now: (today-p (= today-day-number deadline-day-number)) ;; FIXME: Unused for now: (today-p (= today-day-number deadline-day-number))
(deadline-passed-fraction (--> (- deadline-day-number today-day-number) (deadline-passed-fraction (--> (- deadline-day-number today-day-number)
(float it) (float it)
(/ it (max org-deadline-warning-days 1)) (/ it (max org-deadline-warning-days 1))
(- 1 it))) (- 1 it)))
(face (org-agenda-deadline-face deadline-passed-fraction)) (face (org-agenda-deadline-face deadline-passed-fraction))
(title (--> (org-element-property :raw-value element) (title (--> (org-element-property :raw-value element)
(org-add-props it nil (org-add-props it nil
'face face))) 'face face)))
(properties (--> (cadr element) (properties (--> (cadr element)
(plist-put it :title title) (plist-put it :title title)
(plist-put it :relative-due-date relative-due-date)))) (plist-put it :relative-due-date relative-due-date))))
(list (car element) (list (car element)
properties)) properties))
;; No deadline ;; No deadline
@ -1117,7 +1117,7 @@ The counterpart to `org-ql-view--contract-buffers-files'."
"todo") "todo")
nil nil (when org-ql-view-sort nil nil (when org-ql-view-sort
(prin1-to-string org-ql-view-sort))) (prin1-to-string org-ql-view-sort)))
(--remove (equal "buffer-order" it))))) (--remove (equal "buffer-order" it)))))
(pcase input (pcase input
('nil nil) ('nil nil)
((and (pred listp) sort) ((and (pred listp) sort)

View file

@ -584,7 +584,7 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
(cond ((and (listp inherited) (cond ((and (listp inherited)
(listp local)) (listp local))
(->> (append inherited local) (->> (append inherited local)
-non-nil -uniq)) -non-nil -uniq))
((listp inherited) inherited) ((listp inherited) inherited)
((listp local) local))))) ((listp local) local)))))
(cl-typecase org-use-tag-inheritance (cl-typecase org-use-tag-inheritance
@ -680,8 +680,8 @@ from within ELEMENT's buffer."
;; time? I don't know, but for now, it seems that we have to use `copy-marker'. ;; time? I don't know, but for now, it seems that we have to use `copy-marker'.
(let* ((marker (copy-marker (org-element-property :begin element))) (let* ((marker (copy-marker (org-element-property :begin element)))
(properties (--> (cadr element) (properties (--> (cadr element)
(plist-put it :org-marker marker) (plist-put it :org-marker marker)
(plist-put it :org-hd-marker marker)))) (plist-put it :org-hd-marker marker))))
(setf (cadr element) properties) (setf (cadr element) properties)
element)) element))
@ -922,16 +922,16 @@ value of `org-ql-predicates')."
(let* ((names (--map (symbol-name (plist-get (cdr it) :name)) (let* ((names (--map (symbol-name (plist-get (cdr it) :name))
predicates)) predicates))
(aliases (->> predicates (aliases (->> predicates
(--map (plist-get (cdr it) :aliases)) (--map (plist-get (cdr it) :aliases))
-non-nil -non-nil
-flatten -flatten
(-map #'symbol-name))) (-map #'symbol-name)))
(predicate-names (->> (append names aliases) (predicate-names (->> (append names aliases)
-uniq -uniq
;; Sort the keywords longest-first to work around what seems to be an ;; Sort the keywords longest-first to work around what seems to be an
;; obscure bug in `peg': when one keyword is a substring of another, ;; obscure bug in `peg': when one keyword is a substring of another,
;; and the shorter one is listed first, the shorter one fails to match. ;; and the shorter one is listed first, the shorter one fails to match.
(-sort (-on #'> #'length)))) (-sort (-on #'> #'length))))
(pexs `((query (+ (and term (* [blank])))) (pexs `((query (+ (and term (* [blank]))))
(term (or (and negation (list positive-term) (term (or (and negation (list positive-term)
;; This is a bit confusing, but it seems to work. There's probably a better way. ;; This is a bit confusing, but it seems to work. There's probably a better way.
@ -1003,8 +1003,8 @@ manually; see the definition of `org-ql-defpred').")
"Define function `org-ql--normalize-query' for PREDICATES. "Define function `org-ql--normalize-query' for PREDICATES.
PREDICATES should be the value of `org-ql-predicates'." PREDICATES should be the value of `org-ql-predicates'."
(let ((normalizer-patterns (->> predicates (let ((normalizer-patterns (->> predicates
(--map (plist-get (cdr it) :normalizers)) (--map (plist-get (cdr it) :normalizers))
(-flatten-n 1)))) (-flatten-n 1))))
(fset 'org-ql--normalize-query (fset 'org-ql--normalize-query
(byte-compile (byte-compile
`(lambda (query) `(lambda (query)
@ -1274,33 +1274,33 @@ result form."
(when from (when from
(setq from (pcase from (setq from (pcase from
((or 'today "today") (->> (ts-now) ((or 'today "today") (->> (ts-now)
(ts-apply :hour 0 :minute 0 :second 0))) (ts-apply :hour 0 :minute 0 :second 0)))
((pred numberp) (->> (ts-now) ((pred numberp) (->> (ts-now)
(ts-adjust 'day from) (ts-adjust 'day from)
(ts-apply :hour 0 :minute 0 :second 0))) (ts-apply :hour 0 :minute 0 :second 0)))
((and (pred stringp) ((and (pred stringp)
(guard (ignore-errors (cl-parse-integer from)))) (guard (ignore-errors (cl-parse-integer from))))
;; The `pcase' `let' pattern doesn't bind values in the ;; The `pcase' `let' pattern doesn't bind values in the
;; body forms, so we have to parse the integer again. ;; body forms, so we have to parse the integer again.
(->> (ts-now) (->> (ts-now)
(ts-adjust 'day (cl-parse-integer from)) (ts-adjust 'day (cl-parse-integer from))
(ts-apply :hour 0 :minute 0 :second 0))) (ts-apply :hour 0 :minute 0 :second 0)))
((pred stringp) (ts-parse-fill 'begin from)) ((pred stringp) (ts-parse-fill 'begin from))
((pred ts-p) from)))) ((pred ts-p) from))))
(when to (when to
(setq to (pcase to (setq to (pcase to
((or 'today "today") (->> (ts-now) ((or 'today "today") (->> (ts-now)
(ts-apply :hour 23 :minute 59 :second 59))) (ts-apply :hour 23 :minute 59 :second 59)))
((pred numberp) (->> (ts-now) ((pred numberp) (->> (ts-now)
(ts-adjust 'day to) (ts-adjust 'day to)
(ts-apply :hour 23 :minute 59 :second 59))) (ts-apply :hour 23 :minute 59 :second 59)))
((and (pred stringp) ((and (pred stringp)
(guard (ignore-errors (cl-parse-integer to)))) (guard (ignore-errors (cl-parse-integer to))))
;; The `pcase' `let' pattern doesn't bind values in the ;; The `pcase' `let' pattern doesn't bind values in the
;; body forms, so we have to parse the integer again. ;; body forms, so we have to parse the integer again.
(->> (ts-now) (->> (ts-now)
(ts-adjust 'day (cl-parse-integer to)) (ts-adjust 'day (cl-parse-integer to))
(ts-apply :hour 23 :minute 59 :second 59))) (ts-apply :hour 23 :minute 59 :second 59)))
((pred stringp) (ts-parse-fill 'end to)) ((pred stringp) (ts-parse-fill 'end to))
((pred ts-p) to)))) ((pred ts-p) to))))
(setf result (progn ,@body)) (setf result (progn ,@body))
@ -2219,8 +2219,8 @@ non-nil if entry has a deadline."
:normalizers ((`(,predicate-names auto . ,rest) :normalizers ((`(,predicate-names auto . ,rest)
;; Use `org-deadline-warning-days' as the :to arg. ;; Use `org-deadline-warning-days' as the :to arg.
(let ((ts (->> (ts-now) (let ((ts (->> (ts-now)
(ts-adjust 'day org-deadline-warning-days) (ts-adjust 'day org-deadline-warning-days)
(ts-apply :hour 23 :minute 59 :second 59)))) (ts-apply :hour 23 :minute 59 :second 59))))
`(deadline-warning :to ,ts ,@rest))) `(deadline-warning :to ,ts ,@rest)))
(`(,predicate-names . ,(and rest (guard (numberp (car rest))))) (`(,predicate-names . ,(and rest (guard (numberp (car rest)))))
(org-ql--normalize-from-to-on (org-ql--normalize-from-to-on

View file

@ -105,9 +105,9 @@ Set at runtime by test suite.")
"Return buffer visiting FILENAME. "Return buffer visiting FILENAME.
FILENAME should be a file in the \"tests\" directory." FILENAME should be a file in the \"tests\" directory."
(->> (locate-dominating-file default-directory ".git") (->> (locate-dominating-file default-directory ".git")
(expand-file-name "tests") (expand-file-name "tests")
(expand-file-name filename) (expand-file-name filename)
find-file-noselect)) find-file-noselect))
;;;; Macros ;;;; Macros