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
`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.

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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."

View File

@ -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))

View File

@ -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

View File

@ -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

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.
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)