From 315e2dc447cc33791edf1118e56f80d1c41faa82 Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Wed, 24 Mar 2021 14:24:40 +0800 Subject: [PATCH] fix lints --- org-roam-capture.el | 15 ++++++++------- org-roam-completion.el | 17 ++++++++++------- org-roam-dailies.el | 13 +++++-------- org-roam-link.el | 6 ------ org-roam-mode.el | 1 + org-roam-ref.el | 2 ++ org-roam-reflinks.el | 4 ++-- org-roam-unlinked-references.el | 2 ++ org-roam-utils.el | 17 +++++++++++------ org-roam.el | 10 +--------- 10 files changed, 42 insertions(+), 45 deletions(-) diff --git a/org-roam-capture.el b/org-roam-capture.el index cd9cca6..f0aefe5 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -304,13 +304,14 @@ of var is prompted for via `completing-read'. Next, it expands the remaining template string using `org-capture-fill-template'." - (-> str - (s-format (lambda (key) - (or (s--aget org-roam-capture--info key) - (when-let ((val (completing-read (format "%s: " key) nil))) - (push (cons key val) org-roam-capture--info) - val))) nil) - (org-capture-fill-template))) + (org-capture-fill-template + (s-format str + (lambda (key) + (or (s--aget org-roam-capture--info key) + (when-let ((val (completing-read (format "%s: " key) nil))) + (push (cons key val) org-roam-capture--info) + val))) + nil))) (defun org-roam-capture--save-file-maybe () "Save the file conditionally. diff --git a/org-roam-completion.el b/org-roam-completion.el index 54693c8..f8af741 100644 --- a/org-roam-completion.el +++ b/org-roam-completion.el @@ -31,13 +31,17 @@ ;;; Code: (require 'cl-lib) +(declare-function org-roam--get-titles "org-roam") + (defcustom org-roam-completion-ignore-case t "Whether to ignore case in Org-roam `completion-at-point' completions." :group 'org-roam :type 'boolean) (defcustom org-roam-completion-everywhere nil - "When non-nil, provide link completion matching outside of Org links.") + "When non-nil, provide link completion matching outside of Org links." + :group 'org-roam + :type 'boolean) (defvar org-roam-completion-functions (list #'org-roam-complete-link-at-point #'org-roam-complete-everywhere) @@ -78,7 +82,7 @@ This is a `completion-at-point' function, and is active when "Do appropriate completion for the link at point." (let ((end (point)) (start (point)) - collection path) + collection link-type) (when (org-in-regexp org-link-bracket-re 1) (setq start (match-beginning 1) end (match-end 1)) @@ -86,11 +90,10 @@ This is a `completion-at-point' function, and is active when (pcase (org-element-lineage context '(link) t) (`nil nil) (link - (setq link-type (org-element-property :type link) - path (org-element-property :path link)) - (when (member link-type '("roam" "fuzzy")) - (when (string= link-type "roam") (setq start (+ start (length "roam:")))) - (setq collection #'org-roam-link--get-nodes)))))) + (let ((link-type (org-element-property :type link))) + (when (member link-type '("roam" "fuzzy")) + (when (string= link-type "roam") (setq start (+ start (length "roam:")))) + (setq collection #'org-roam--get-titles))))))) (when collection (let ((prefix (buffer-substring-no-properties start end))) (list start end diff --git a/org-roam-dailies.el b/org-roam-dailies.el index 3f1fcef..55804dc 100644 --- a/org-roam-dailies.el +++ b/org-roam-dailies.el @@ -139,8 +139,7 @@ Template string :\n%v") If FILE is not specified, use the current buffer's file-path." (when-let ((path (or file - (-> (buffer-base-buffer) - (buffer-file-name)))) + (buffer-base-buffer (buffer-file-name)))) (directory (org-roam-dailies-directory--get-absolute-path))) (setq path (expand-file-name path)) (save-match-data @@ -231,13 +230,11 @@ future." Return (MONTH DAY YEAR)." (let ((file (or file - (-> (buffer-base-buffer) - (buffer-file-name))))) + (buffer-base-buffer (buffer-file-name))))) (cl-destructuring-bind (_ _ _ d m y _ _ _) - (-> file - (file-name-nondirectory) - (file-name-sans-extension) - (org-parse-time-string)) + (org-parse-time-string + (file-name-sans-extension + (file-name-nondirectory file))) (list m d y)))) (defun org-roam-dailies-calendar--date-to-time (date) diff --git a/org-roam-link.el b/org-roam-link.el index 358d5c7..8854f55 100644 --- a/org-roam-link.el +++ b/org-roam-link.el @@ -110,12 +110,6 @@ in the file." (cdr (assoc choice matches #'string-equal)))))))))) ;;; Retrieval Functions -(defun org-roam-link--get-nodes () - "Return all node title and aliases." - (append - (mapcar #'car (org-roam-db-query [:select [title] :from nodes])) - (mapcar #'car (org-roam-db-query [:select [alias] :from aliases])))) - (defun org-roam-link--get-node-from-title (title) "Return the node id for a given TITLE." (let ((nodes (seq-uniq diff --git a/org-roam-mode.el b/org-roam-mode.el index ccd4391..5bb2e55 100644 --- a/org-roam-mode.el +++ b/org-roam-mode.el @@ -37,6 +37,7 @@ (defvar org-roam-directory) (declare-function org-roam--org-file-p "org-roam") +(declare-function org-roam-node-at-point "org-roam-node") ;;; Faces (defface org-roam-header-line diff --git a/org-roam-ref.el b/org-roam-ref.el index 40543bd..73386e4 100644 --- a/org-roam-ref.el +++ b/org-roam-ref.el @@ -33,6 +33,8 @@ ;; ;;; Code: ;;;; Library Requires +(require 'org-roam-db) + (defun org-roam-ref--completions () "Return an alist for ref completion. The car is the ref, and the cdr is the corresponding node for the ref." diff --git a/org-roam-reflinks.el b/org-roam-reflinks.el index c719519..bf2d311 100644 --- a/org-roam-reflinks.el +++ b/org-roam-reflinks.el @@ -32,13 +32,13 @@ ;;; Code: ;;;; Library Requires (require 'magit-section) +(require 'org-roam-db) (require 'org-roam-structs) (defvar org-roam-mode-sections) (defvar org-roam-mode-map) -;;; Section -;;;; Definition +(declare-function org-roam-node-insert-section "org-roam-node") ;;; Functions (cl-defmethod org-roam-populate ((reflink org-roam-reflink)) diff --git a/org-roam-unlinked-references.el b/org-roam-unlinked-references.el index 7f5a1bb..9024219 100644 --- a/org-roam-unlinked-references.el +++ b/org-roam-unlinked-references.el @@ -37,6 +37,8 @@ (defvar org-roam-file-extensions) (defvar org-roam-directory) +(declare-function org-roam--list-files-search-globs "org-roam") + ;;; Section ;;;; Faces diff --git a/org-roam-utils.el b/org-roam-utils.el index 7226ef3..5c5ec45 100644 --- a/org-roam-utils.el +++ b/org-roam-utils.el @@ -61,17 +61,22 @@ (nconc new-lst (list separator it))) new-lst))) +(defun org-roam-up-heading-or-point-min () + "Fixed version of Org's `org-up-heading-or-point-min'." + (when (ignore-errors (org-back-to-heading t)) + (let ((p (point))) + (if (< 1 (funcall outline-level)) + (progn + (org-up-heading-safe) + (when (= (point) p) + (goto-char (point-min)))) + (unless (= (point) (point-min)) (goto-char (point-min))))))) + (defun org-roam-message (format-string &rest args) "Pass FORMAT-STRING and ARGS to `message' when `org-roam-verbose' is t." (when org-roam-verbose (apply #'message `(,(concat "(org-roam) " format-string) ,@args)))) -(defun org-roam-string-quote (str) - "Quote STR." - (->> str - (s-replace "\\" "\\\\") - (s-replace "\"" "\\\""))) - (defun org-roam-set-header-line-format (string) "Set the header-line using STRING. If the `face' property of any part of STRING is already set, then diff --git a/org-roam.el b/org-roam.el index d934759..720c845 100644 --- a/org-roam.el +++ b/org-roam.el @@ -194,8 +194,7 @@ Like `file-name-extension', but does not strip version number." "Return t if FILE is part of Org-roam system, nil otherwise. If FILE is not specified, use the current buffer's file-path." (when-let ((path (or file - (-> (buffer-base-buffer) - (buffer-file-name))))) + (buffer-base-buffer (buffer-file-name))))) (save-match-data (and (org-roam--org-file-p path) @@ -335,13 +334,6 @@ Use external shell commands if defined in `org-roam-list-files-commands'." "Return a list of all Org-roam files within `org-roam-directory'." (org-roam--list-files (expand-file-name org-roam-directory))) -;;;; Title/Path/Slug conversion -(defun org-roam--path-to-slug (path) - "Return a slug from PATH." - (-> path - (file-relative-name (expand-file-name org-roam-directory)) - (file-name-sans-extension))) - (defun org-roam--title-to-slug (title) "Convert TITLE to a filename-suitable slug." (cl-flet* ((nonspacing-mark-p (char)