mu4e-(actions|control|org|update).el: tidy up

Fix flycheck warnings, and use '--' instead of '~' for private
variables/functions.
This commit is contained in:
Dirk-Jan C. Binnema
2021-08-30 22:02:49 +03:00
parent 162f5896ae
commit 3a39eff1df
5 changed files with 56 additions and 49 deletions

View File

@ -43,7 +43,8 @@
Works for headers view and message-view."
(message "Number of lines: %s"
(shell-command-to-string
(concat "wc -l < " (shell-quote-argument (mu4e-message-field msg :path))))))
(concat "wc -l < "
(shell-quote-argument (mu4e-message-field msg :path))))))
;;; Org Helpers
@ -102,22 +103,22 @@ file where you store your org-contacts."
;;; Patches
(defvar mu4e~patch-directory-history nil
(defvar mu4e--patch-directory-history nil
"History of directories we have applied patches to.")
;; This essentially works around the fact that read-directory-name
;; can't have custom history.
(defun mu4e~read-patch-directory (&optional prompt)
(defun mu4e--read-patch-directory (&optional prompt)
"Read a `PROMPT'ed directory name via `completing-read' with history."
(unless prompt
(setq prompt "Target directory:"))
(file-truename
(completing-read prompt 'read-file-name-internal #'file-directory-p
nil nil 'mu4e~patch-directory-history)))
nil nil 'mu4e--patch-directory-history)))
(defun mu4e-action-git-apply-patch (msg)
"Apply `MSG' as a git patch."
(let ((path (mu4e~read-patch-directory "Target directory: ")))
(let ((path (mu4e--read-patch-directory "Target directory: ")))
(let ((default-directory path))
(shell-command
(format "git apply %s"
@ -130,10 +131,10 @@ If the `default-directory' matches the most recent history entry don't
bother asking for the git tree again (useful for bulk actions)."
(let ((cwd (substring-no-properties
(or (car mu4e~patch-directory-history)
(or (car mu4e--patch-directory-history)
"not-a-dir"))))
(unless (and (stringp cwd) (string= default-directory cwd))
(setq cwd (mu4e~read-patch-directory "Target directory: ")))
(setq cwd (mu4e--read-patch-directory "Target directory: ")))
(let ((default-directory cwd))
(shell-command
(format "git am %s %s"
@ -152,7 +153,7 @@ messages can lead to messages with multiple tags headers.")
(defvar mu4e-action-tags-completion-list '()
"List of tags for completion in `mu4e-action-retag-message'.")
(defun mu4e~contains-line-matching (regexp path)
(defun mu4e--contains-line-matching (regexp path)
"Return non-nil if the file at PATH contain a line matching REGEXP.
Otherwise return nil."
(with-temp-buffer
@ -161,7 +162,7 @@ Otherwise return nil."
(goto-char (point-min))
(re-search-forward regexp nil t))))
(defun mu4e~replace-first-line-matching (regexp to-string path)
(defun mu4e--replace-first-line-matching (regexp to-string path)
"Replace first line matching REGEXP in PATH with TO-STRING."
(with-temp-file path
(insert-file-contents path)
@ -220,13 +221,13 @@ would add 'tag' and 'long tag', and remove 'oldtag'."
(setq tagstr (replace-regexp-in-string "[\\&]" "\\\\\\&" tagstr))
(setq tagstr (replace-regexp-in-string "[/]" "\\&" tagstr))
(if (not (mu4e~contains-line-matching (concat header ":.*") path))
(if (not (mu4e--contains-line-matching (concat header ":.*") path))
;; Add tags header just before the content
(mu4e~replace-first-line-matching
(mu4e--replace-first-line-matching
"^$" (concat header ": " tagstr "\n") path)
;; replaces keywords, restricted to the header
(mu4e~replace-first-line-matching
(mu4e--replace-first-line-matching
(concat header ":.*")
(concat header ": " tagstr)
path))