From 7a8e3b2e8e2ed758e29e7690035cc245ae93b718 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 8 Jun 2021 10:53:13 -0500 Subject: [PATCH] Tidy: Indentation Due to changes in dash. --- helm-org-ql.el | 8 ++-- org-ql-search.el | 10 ++-- org-ql-view.el | 92 ++++++++++++++++++------------------ org-ql.el | 108 +++++++++++++++++++++---------------------- tests/test-org-ql.el | 6 +-- 5 files changed, 112 insertions(+), 112 deletions(-) diff --git a/helm-org-ql.el b/helm-org-ql.el index 6757488..30f0a3f 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 c60bd8e..c7c979f 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -224,9 +224,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 @@ -343,8 +343,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 f7b9a6e..ff9c80f 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) @@ -271,8 +271,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 @@ -394,12 +394,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) @@ -468,8 +468,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)) @@ -748,8 +748,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))))) (define-infix-command org-ql-view--transient-title () ;; TODO: Add an asterisk or something when the view has been modified but not saved. @@ -848,8 +848,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 @@ -870,9 +870,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) @@ -888,19 +888,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." @@ -957,11 +957,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 @@ -983,16 +983,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 @@ -1113,7 +1113,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 2025f0b..1fbf366 100644 --- a/org-ql.el +++ b/org-ql.el @@ -216,18 +216,18 @@ returns nil or non-nil." (function (funcall buffers-or-files)) (list buffers-or-files) (otherwise (list buffers-or-files))) - (--map (cl-etypecase it - ;; NOTE: This etypecase is essential to opening links safely, - ;; as it rejects, e.g. lambdas in the buffers-files argument. - (buffer it) - (string (or (find-buffer-visiting it) - (when (file-readable-p it) - ;; It feels unintuitive that `find-file-noselect' returns - ;; a buffer if the filename doesn't exist. - (find-file-noselect it)) - (user-error "Can't open file: %s" it))))) - ;; Ignore special/hidden buffers. - (--remove (string-prefix-p " " (buffer-name it))))) + (--map (cl-etypecase it + ;; NOTE: This etypecase is essential to opening links safely, + ;; as it rejects, e.g. lambdas in the buffers-files argument. + (buffer it) + (string (or (find-buffer-visiting it) + (when (file-readable-p it) + ;; It feels unintuitive that `find-file-noselect' returns + ;; a buffer if the filename doesn't exist. + (find-file-noselect it)) + (user-error "Can't open file: %s" it))))) + ;; Ignore special/hidden buffers. + (--remove (string-prefix-p " " (buffer-name it))))) (query (org-ql--normalize-query query)) ((&plist :query :preamble :preamble-case-fold) (org-ql--query-preamble query)) (predicate (org-ql--query-predicate query)) @@ -263,12 +263,12 @@ returns nil or non-nil." (fset name fn))) ;; Run query on buffers. (->> buffers - (--map (with-current-buffer it - (unless (derived-mode-p 'org-mode) - (user-error "Not an Org buffer: %s" (buffer-name))) - (org-ql--select-cached :query query :preamble preamble :preamble-case-fold preamble-case-fold - :predicate predicate :action action :narrow narrow))) - (-flatten-n 1))) + (--map (with-current-buffer it + (unless (derived-mode-p 'org-mode) + (user-error "Not an Org buffer: %s" (buffer-name))) + (org-ql--select-cached :query query :preamble preamble :preamble-case-fold preamble-case-fold + :predicate predicate :action action :narrow narrow))) + (-flatten-n 1))) (--each orig-fns ;; Restore original function mappings. (-let (((&plist :name :fn) it)) @@ -422,7 +422,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 @@ -518,8 +518,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)) @@ -675,16 +675,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 (+ term (opt (+ (syntax-class whitespace) (any))))) (term (or (and negation (list positive-term) @@ -757,8 +757,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) @@ -969,33 +969,33 @@ predicates." (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)))))) @@ -1628,8 +1628,8 @@ parseable by `parse-time-string' which may omit the time value." :normalizers ((`(,predicate-names ,(and num-days (pred numberp))) ;; (clocked) and (closed) implicitly look into the past. (let ((from (->> (ts-now) - (ts-adjust 'day (* -1 num-days)) - (ts-apply :hour 0 :minute 0 :second 0)))) + (ts-adjust 'day (* -1 num-days)) + (ts-apply :hour 0 :minute 0 :second 0)))) `(clocked :from ,from)))) :preambles ((`(,predicate-names ,(pred numberp)) (list :regexp org-ql-clock-regexp :query t)) @@ -1658,8 +1658,8 @@ parseable by `parse-time-string' which may omit the time value." :normalizers ((`(,predicate-names ,(and num-days (pred numberp))) ;; (clocked) and (closed) implicitly look into the past. (let ((from (->> (ts-now) - (ts-adjust 'day (* -1 num-days)) - (ts-apply :hour 0 :minute 0 :second 0)))) + (ts-adjust 'day (* -1 num-days)) + (ts-apply :hour 0 :minute 0 :second 0)))) `(closed :from ,from)))) :preambles ((`(,predicate-names . ,_) ;; Predicate still needs testing. @@ -1688,13 +1688,13 @@ parseable by `parse-time-string' which may omit the time value." :normalizers ((`(,predicate-names auto) ;; Use `org-deadline-warning-days' as the :to arg. (let ((to (->> (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 ,to))) (`(,predicate-names ,(and num-days (pred numberp))) (let ((to (->> (ts-now) - (ts-adjust 'day num-days) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day num-days) + (ts-apply :hour 23 :minute 59 :second 59)))) `(deadline :to ,to)))) ;; NOTE: Does this normalizer cause the preamble to not be used? (Adding one to the deadline-warning definition to be sure.) :preambles ((`(,predicate-names . ,_) @@ -1750,8 +1750,8 @@ FROM, TO, and ON should be either `ts' structs, or strings parseable by `parse-time-string' which may omit the time value." :normalizers ((`(,predicate-names ,(and num-days (pred numberp))) (let ((to (->> (ts-now) - (ts-adjust 'day num-days) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day num-days) + (ts-apply :hour 23 :minute 59 :second 59)))) `(planning :to ,to)))) :preambles ((`(,predicate-names . ,_) (list :regexp org-ql-planning-regexp :query query))) @@ -1778,8 +1778,8 @@ FROM, TO, and ON should be either `ts' structs, or strings parseable by `parse-time-string' which may omit the time value." :normalizers ((`(,predicate-names ,(and num-days (pred numberp))) (let ((to (->> (ts-now) - (ts-adjust 'day num-days) - (ts-apply :hour 23 :minute 59 :second 59)))) + (ts-adjust 'day num-days) + (ts-apply :hour 23 :minute 59 :second 59)))) `(scheduled :to ,to)))) :preambles ((`(,predicate-names . ,_) (list :regexp org-scheduled-time-regexp :query query))) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index f294c70..d21b6b2 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