fix lints

This commit is contained in:
Jethro Kuan
2021-03-24 14:24:40 +08:00
parent 2f77ae709d
commit 315e2dc447
10 changed files with 42 additions and 45 deletions

View File

@ -304,13 +304,14 @@ of var is prompted for via `completing-read'.
Next, it expands the remaining template string using Next, it expands the remaining template string using
`org-capture-fill-template'." `org-capture-fill-template'."
(-> str (org-capture-fill-template
(s-format (lambda (key) (s-format str
(lambda (key)
(or (s--aget org-roam-capture--info key) (or (s--aget org-roam-capture--info key)
(when-let ((val (completing-read (format "%s: " key) nil))) (when-let ((val (completing-read (format "%s: " key) nil)))
(push (cons key val) org-roam-capture--info) (push (cons key val) org-roam-capture--info)
val))) nil) val)))
(org-capture-fill-template))) nil)))
(defun org-roam-capture--save-file-maybe () (defun org-roam-capture--save-file-maybe ()
"Save the file conditionally. "Save the file conditionally.

View File

@ -31,13 +31,17 @@
;;; Code: ;;; Code:
(require 'cl-lib) (require 'cl-lib)
(declare-function org-roam--get-titles "org-roam")
(defcustom org-roam-completion-ignore-case t (defcustom org-roam-completion-ignore-case t
"Whether to ignore case in Org-roam `completion-at-point' completions." "Whether to ignore case in Org-roam `completion-at-point' completions."
:group 'org-roam :group 'org-roam
:type 'boolean) :type 'boolean)
(defcustom org-roam-completion-everywhere nil (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 (defvar org-roam-completion-functions (list #'org-roam-complete-link-at-point
#'org-roam-complete-everywhere) #'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." "Do appropriate completion for the link at point."
(let ((end (point)) (let ((end (point))
(start (point)) (start (point))
collection path) collection link-type)
(when (org-in-regexp org-link-bracket-re 1) (when (org-in-regexp org-link-bracket-re 1)
(setq start (match-beginning 1) (setq start (match-beginning 1)
end (match-end 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) (pcase (org-element-lineage context '(link) t)
(`nil nil) (`nil nil)
(link (link
(setq link-type (org-element-property :type link) (let ((link-type (org-element-property :type link)))
path (org-element-property :path link))
(when (member link-type '("roam" "fuzzy")) (when (member link-type '("roam" "fuzzy"))
(when (string= link-type "roam") (setq start (+ start (length "roam:")))) (when (string= link-type "roam") (setq start (+ start (length "roam:"))))
(setq collection #'org-roam-link--get-nodes)))))) (setq collection #'org-roam--get-titles)))))))
(when collection (when collection
(let ((prefix (buffer-substring-no-properties start end))) (let ((prefix (buffer-substring-no-properties start end)))
(list start end (list start end

View File

@ -139,8 +139,7 @@ Template string :\n%v")
If FILE is not specified, use the current buffer's file-path." If FILE is not specified, use the current buffer's file-path."
(when-let ((path (or file (when-let ((path (or file
(-> (buffer-base-buffer) (buffer-base-buffer (buffer-file-name))))
(buffer-file-name))))
(directory (org-roam-dailies-directory--get-absolute-path))) (directory (org-roam-dailies-directory--get-absolute-path)))
(setq path (expand-file-name path)) (setq path (expand-file-name path))
(save-match-data (save-match-data
@ -231,13 +230,11 @@ future."
Return (MONTH DAY YEAR)." Return (MONTH DAY YEAR)."
(let ((file (or file (let ((file (or file
(-> (buffer-base-buffer) (buffer-base-buffer (buffer-file-name)))))
(buffer-file-name)))))
(cl-destructuring-bind (_ _ _ d m y _ _ _) (cl-destructuring-bind (_ _ _ d m y _ _ _)
(-> file (org-parse-time-string
(file-name-nondirectory) (file-name-sans-extension
(file-name-sans-extension) (file-name-nondirectory file)))
(org-parse-time-string))
(list m d y)))) (list m d y))))
(defun org-roam-dailies-calendar--date-to-time (date) (defun org-roam-dailies-calendar--date-to-time (date)

View File

@ -110,12 +110,6 @@ in the file."
(cdr (assoc choice matches #'string-equal)))))))))) (cdr (assoc choice matches #'string-equal))))))))))
;;; Retrieval Functions ;;; 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) (defun org-roam-link--get-node-from-title (title)
"Return the node id for a given TITLE." "Return the node id for a given TITLE."
(let ((nodes (seq-uniq (let ((nodes (seq-uniq

View File

@ -37,6 +37,7 @@
(defvar org-roam-directory) (defvar org-roam-directory)
(declare-function org-roam--org-file-p "org-roam") (declare-function org-roam--org-file-p "org-roam")
(declare-function org-roam-node-at-point "org-roam-node")
;;; Faces ;;; Faces
(defface org-roam-header-line (defface org-roam-header-line

View File

@ -33,6 +33,8 @@
;; ;;
;;; Code: ;;; Code:
;;;; Library Requires ;;;; Library Requires
(require 'org-roam-db)
(defun org-roam-ref--completions () (defun org-roam-ref--completions ()
"Return an alist for ref completion. "Return an alist for ref completion.
The car is the ref, and the cdr is the corresponding node for the ref." The car is the ref, and the cdr is the corresponding node for the ref."

View File

@ -32,13 +32,13 @@
;;; Code: ;;; Code:
;;;; Library Requires ;;;; Library Requires
(require 'magit-section) (require 'magit-section)
(require 'org-roam-db)
(require 'org-roam-structs) (require 'org-roam-structs)
(defvar org-roam-mode-sections) (defvar org-roam-mode-sections)
(defvar org-roam-mode-map) (defvar org-roam-mode-map)
;;; Section (declare-function org-roam-node-insert-section "org-roam-node")
;;;; Definition
;;; Functions ;;; Functions
(cl-defmethod org-roam-populate ((reflink org-roam-reflink)) (cl-defmethod org-roam-populate ((reflink org-roam-reflink))

View File

@ -37,6 +37,8 @@
(defvar org-roam-file-extensions) (defvar org-roam-file-extensions)
(defvar org-roam-directory) (defvar org-roam-directory)
(declare-function org-roam--list-files-search-globs "org-roam")
;;; Section ;;; Section
;;;; Faces ;;;; Faces

View File

@ -61,17 +61,22 @@
(nconc new-lst (list separator it))) (nconc new-lst (list separator it)))
new-lst))) 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) (defun org-roam-message (format-string &rest args)
"Pass FORMAT-STRING and ARGS to `message' when `org-roam-verbose' is t." "Pass FORMAT-STRING and ARGS to `message' when `org-roam-verbose' is t."
(when org-roam-verbose (when org-roam-verbose
(apply #'message `(,(concat "(org-roam) " format-string) ,@args)))) (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) (defun org-roam-set-header-line-format (string)
"Set the header-line using STRING. "Set the header-line using STRING.
If the `face' property of any part of STRING is already set, then If the `face' property of any part of STRING is already set, then

View File

@ -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. "Return t if FILE is part of Org-roam system, nil otherwise.
If FILE is not specified, use the current buffer's file-path." If FILE is not specified, use the current buffer's file-path."
(when-let ((path (or file (when-let ((path (or file
(-> (buffer-base-buffer) (buffer-base-buffer (buffer-file-name)))))
(buffer-file-name)))))
(save-match-data (save-match-data
(and (and
(org-roam--org-file-p path) (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'." "Return a list of all Org-roam files within `org-roam-directory'."
(org-roam--list-files (expand-file-name 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) (defun org-roam--title-to-slug (title)
"Convert TITLE to a filename-suitable slug." "Convert TITLE to a filename-suitable slug."
(cl-flet* ((nonspacing-mark-p (char) (cl-flet* ((nonspacing-mark-p (char)