From a5fbb5d9767a2cb777f2cf44873b252a5d7e2931 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Mar 2023 00:01:32 -0600 Subject: [PATCH] Tidy: Indentation of dash forms See, e.g. . 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!) --- helm-org-ql.el | 8 ++-- org-ql-search.el | 10 ++--- org-ql-view.el | 92 ++++++++++++++++++++++---------------------- org-ql.el | 52 ++++++++++++------------- tests/test-org-ql.el | 6 +-- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/helm-org-ql.el b/helm-org-ql.el index 38b9722..02eff9a 100644 --- a/helm-org-ql.el +++ b/helm-org-ql.el @@ -59,8 +59,8 @@ Based on `helm-map'.") (helm-make-source "Org QL Views" 'helm-source-sync :candidates (lambda () (->> org-ql-views - (-map #'car) - (-sort #'string<))) + (-map #'car) + (-sort #'string<))) :action (list (cons "Show view" #'org-ql-view))) "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))) (heading (org-get-heading t)) (path (-> (org-get-outline-path) - (org-format-outline-path width nil "") - (org-split-string ""))) + (org-format-outline-path width nil "") + (org-split-string ""))) (path (if helm-org-ql-reverse-paths (concat heading "\\" (s-join "\\" (nreverse path))) (concat (s-join "/" path) "/" heading)))) diff --git a/org-ql-search.el b/org-ql-search.el index aa75656..c98f1e4 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -233,9 +233,9 @@ automatically from the query." ;; `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. (->> items - (-map #'org-ql-view--format-element) - org-agenda-finalize-entries - insert) + (-map #'org-ql-view--format-element) + org-agenda-finalize-entries + insert) (insert "\n")))) ;;;###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 REGEXP is non-nil, only return files that match REGEXP." (let ((files (->> directories - (--map (f-files it nil recurse)) - -flatten))) + (--map (f-files it nil recurse)) + -flatten))) (if regexp (--select (string-match regexp it) files) diff --git a/org-ql-view.el b/org-ql-view.el index 74f74d9..13cde85 100644 --- a/org-ql-view.el +++ b/org-ql-view.el @@ -153,11 +153,11 @@ See info node `(elisp)Cyclic Window Ordering'." (interactive) (let* ((ts (ts-now)) (beg-of-week (->> ts - (ts-adjust 'day (- (ts-dow (ts-now)))) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (- (ts-dow (ts-now)))) + (ts-apply :hour 0 :minute 0 :second 0))) (end-of-week (->> ts - (ts-adjust 'day (- 6 (ts-dow (ts-now)))) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day (- 6 (ts-dow (ts-now)))) + (ts-apply :hour 23 :minute 59 :second 59)))) (org-ql-search (org-agenda-files) `(ts-active :from ,beg-of-week :to ,end-of-week) @@ -170,11 +170,11 @@ See info node `(elisp)Cyclic Window Ordering'." (interactive) (let* ((ts (ts-adjust 'day 7 (ts-now))) (beg-of-week (->> ts - (ts-adjust 'day (- (ts-dow (ts-now)))) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (- (ts-dow (ts-now)))) + (ts-apply :hour 0 :minute 0 :second 0))) (end-of-week (->> ts - (ts-adjust 'day (- 6 (ts-dow (ts-now)))) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day (- 6 (ts-dow (ts-now)))) + (ts-apply :hour 23 :minute 59 :second 59)))) (org-ql-search (org-agenda-files) `(ts-active :from ,beg-of-week :to ,end-of-week) @@ -272,8 +272,8 @@ TYPE may be `ts', `ts-active', `ts-inactive', `clocked', or `closed'." (interactive (list :num-days (read-number "Days: ") :type (->> '(ts ts-active ts-inactive clocked closed) - (completing-read "Timestamp type: ") - intern))) + (completing-read "Timestamp type: ") + intern))) ;; 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. (-let* ((query (pcase-exhaustive type @@ -395,12 +395,12 @@ update search arguments." (let ((inhibit-read-only t)) (erase-buffer) (->> org-ql-views - (-map #'car) - (-sort (if org-ql-view-sidebar-sort-views - #'string< - #'ignore)) - (s-join "\n") - insert)) + (-map #'car) + (-sort (if org-ql-view-sidebar-sort-views + #'string< + #'ignore)) + (s-join "\n") + insert)) (current-buffer))) (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)))) (buffers-files-formatted (when buffers-files-formatted (propertize (->> buffers-files-formatted - (org-ql-view--font-lock-string 'emacs-lisp-mode) - (s-truncate available-width)) + (org-ql-view--font-lock-string 'emacs-lisp-mode) + (s-truncate available-width)) 'help-echo buffers-files-formatted)))) (concat title (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) (concat (propertize key 'face 'transient-argument) ": " (->> value - org-ql-view--format-query - (org-ql-view--font-lock-string 'emacs-lisp-mode))))) + org-ql-view--format-query + (org-ql-view--font-lock-string 'emacs-lisp-mode))))) (transient-define-infix org-ql-view--transient-title () ;; 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 ;; (which would also make it easier to do it independently of faces, etc). (title (--> (org-ql-view--add-faces element) - (org-element-property :raw-value it) - (org-link-display-format it))) + (org-element-property :raw-value it) + (org-link-display-format it))) (todo-keyword (-some--> (org-element-property :todo-keyword element) (org-ql-view--add-todo-face it))) (tag-list (if org-use-tag-inheritance @@ -872,9 +872,9 @@ return an empty string." (org-element-property :tags element))) (tag-string (when tag-list (--> tag-list - (s-join ":" it) - (s-wrap it ":") - (org-add-props it nil 'face 'org-tag)))) + (s-join ":" it) + (s-wrap it ":") + (org-add-props it nil 'face 'org-tag)))) ;; (category (org-element-property :category element)) (priority-string (-some->> (org-element-property :priority element) (char-to-string) @@ -890,19 +890,19 @@ return an empty string." (remove-list-of-text-properties 0 (length string) '(line-prefix) string) ;; Add all the necessary properties and faces to the whole string (--> string - ;; FIXME: Use proper prefix - (concat " " it) - (org-add-props it properties - 'org-agenda-type 'search - 'todo-state todo-keyword - 'tags tag-list - 'org-habit-p habit-property))))) + ;; FIXME: Use proper prefix + (concat " " it) + (org-add-props it properties + 'org-agenda-type 'search + 'todo-state todo-keyword + 'tags tag-list + 'org-habit-p habit-property))))) (defun org-ql-view--add-faces (element) "Return ELEMENT with deadline and scheduled faces added." (->> element - (org-ql-view--add-scheduled-face) - (org-ql-view--add-deadline-face))) + (org-ql-view--add-scheduled-face) + (org-ql-view--add-deadline-face))) (defun org-ql-view--add-priority-face (string) "Return STRING with priority face added." @@ -959,11 +959,11 @@ return an empty string." ((> today-day-number scheduled-day-number) 'org-scheduled-previously) (t 'org-scheduled))) (title (--> (org-element-property :raw-value element) - (org-add-props it nil - 'face face))) + (org-add-props it nil + 'face face))) (properties (--> (cadr element) - (plist-put it :title title) - (plist-put it :relative-due-date relative-due-date)))) + (plist-put it :title title) + (plist-put it :relative-due-date relative-due-date)))) (list (car element) properties)) ;; Not scheduled @@ -985,16 +985,16 @@ property." ;; FIXME: Unused for now: (done-p (member todo-keyword org-done-keywords)) ;; FIXME: Unused for now: (today-p (= today-day-number deadline-day-number)) (deadline-passed-fraction (--> (- deadline-day-number today-day-number) - (float it) - (/ it (max org-deadline-warning-days 1)) - (- 1 it))) + (float it) + (/ it (max org-deadline-warning-days 1)) + (- 1 it))) (face (org-agenda-deadline-face deadline-passed-fraction)) (title (--> (org-element-property :raw-value element) - (org-add-props it nil - 'face face))) + (org-add-props it nil + 'face face))) (properties (--> (cadr element) - (plist-put it :title title) - (plist-put it :relative-due-date relative-due-date)))) + (plist-put it :title title) + (plist-put it :relative-due-date relative-due-date)))) (list (car element) properties)) ;; No deadline @@ -1117,7 +1117,7 @@ The counterpart to `org-ql-view--contract-buffers-files'." "todo") nil nil (when org-ql-view-sort (prin1-to-string org-ql-view-sort))) - (--remove (equal "buffer-order" it))))) + (--remove (equal "buffer-order" it))))) (pcase input ('nil nil) ((and (pred listp) sort) diff --git a/org-ql.el b/org-ql.el index ede80b5..0015f1d 100644 --- a/org-ql.el +++ b/org-ql.el @@ -584,7 +584,7 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)." (cond ((and (listp inherited) (listp local)) (->> (append inherited local) - -non-nil -uniq)) + -non-nil -uniq)) ((listp inherited) inherited) ((listp local) local))))) (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'. (let* ((marker (copy-marker (org-element-property :begin element))) (properties (--> (cadr element) - (plist-put it :org-marker marker) - (plist-put it :org-hd-marker marker)))) + (plist-put it :org-marker marker) + (plist-put it :org-hd-marker marker)))) (setf (cadr element) properties) element)) @@ -922,16 +922,16 @@ value of `org-ql-predicates')." (let* ((names (--map (symbol-name (plist-get (cdr it) :name)) predicates)) (aliases (->> predicates - (--map (plist-get (cdr it) :aliases)) - -non-nil - -flatten - (-map #'symbol-name))) + (--map (plist-get (cdr it) :aliases)) + -non-nil + -flatten + (-map #'symbol-name))) (predicate-names (->> (append names aliases) - -uniq - ;; 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, - ;; and the shorter one is listed first, the shorter one fails to match. - (-sort (-on #'> #'length)))) + -uniq + ;; 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, + ;; and the shorter one is listed first, the shorter one fails to match. + (-sort (-on #'> #'length)))) (pexs `((query (+ (and term (* [blank])))) (term (or (and negation (list positive-term) ;; 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. PREDICATES should be the value of `org-ql-predicates'." (let ((normalizer-patterns (->> predicates - (--map (plist-get (cdr it) :normalizers)) - (-flatten-n 1)))) + (--map (plist-get (cdr it) :normalizers)) + (-flatten-n 1)))) (fset 'org-ql--normalize-query (byte-compile `(lambda (query) @@ -1274,33 +1274,33 @@ result form." (when from (setq from (pcase from ((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) - (ts-adjust 'day from) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day from) + (ts-apply :hour 0 :minute 0 :second 0))) ((and (pred stringp) (guard (ignore-errors (cl-parse-integer from)))) ;; The `pcase' `let' pattern doesn't bind values in the ;; body forms, so we have to parse the integer again. (->> (ts-now) - (ts-adjust 'day (cl-parse-integer from)) - (ts-apply :hour 0 :minute 0 :second 0))) + (ts-adjust 'day (cl-parse-integer from)) + (ts-apply :hour 0 :minute 0 :second 0))) ((pred stringp) (ts-parse-fill 'begin from)) ((pred ts-p) from)))) (when to (setq to (pcase to ((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) - (ts-adjust 'day to) - (ts-apply :hour 23 :minute 59 :second 59))) + (ts-adjust 'day to) + (ts-apply :hour 23 :minute 59 :second 59))) ((and (pred stringp) (guard (ignore-errors (cl-parse-integer to)))) ;; The `pcase' `let' pattern doesn't bind values in the ;; body forms, so we have to parse the integer again. (->> (ts-now) - (ts-adjust 'day (cl-parse-integer to)) - (ts-apply :hour 23 :minute 59 :second 59))) + (ts-adjust 'day (cl-parse-integer to)) + (ts-apply :hour 23 :minute 59 :second 59))) ((pred stringp) (ts-parse-fill 'end to)) ((pred ts-p) to)))) (setf result (progn ,@body)) @@ -2219,8 +2219,8 @@ non-nil if entry has a deadline." :normalizers ((`(,predicate-names auto . ,rest) ;; Use `org-deadline-warning-days' as the :to arg. (let ((ts (->> (ts-now) - (ts-adjust 'day org-deadline-warning-days) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day org-deadline-warning-days) + (ts-apply :hour 23 :minute 59 :second 59)))) `(deadline-warning :to ,ts ,@rest))) (`(,predicate-names . ,(and rest (guard (numberp (car rest))))) (org-ql--normalize-from-to-on diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 25ac617..fbccd80 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -105,9 +105,9 @@ Set at runtime by test suite.") "Return buffer visiting FILENAME. FILENAME should be a file in the \"tests\" directory." (->> (locate-dominating-file default-directory ".git") - (expand-file-name "tests") - (expand-file-name filename) - find-file-noselect)) + (expand-file-name "tests") + (expand-file-name filename) + find-file-noselect)) ;;;; Macros