mirror of https://github.com/djcb/mu.git
* mu4e: don't use beginning-of-buffer non-interactively (fixes compilation warning)
This commit is contained in:
parent
893cde89b9
commit
9c7d2e3b16
|
@ -194,17 +194,19 @@ store your org-contacts."
|
||||||
the given regexp."
|
the given regexp."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents path)
|
(insert-file-contents path)
|
||||||
(save-excursion (beginning-of-buffer)
|
(save-excursion
|
||||||
(if (re-search-forward regexp nil t)
|
(goto-char (point-min))
|
||||||
t
|
(if (re-search-forward regexp nil t)
|
||||||
nil))))
|
t
|
||||||
|
nil))))
|
||||||
|
|
||||||
(defun mu4e~replace-first-line-matching (regexp to-string path)
|
(defun mu4e~replace-first-line-matching (regexp to-string path)
|
||||||
"Replace the first line in the file at path that matches regexp
|
"Replace the first line in the file at path that matches regexp
|
||||||
with the string replace."
|
with the string replace."
|
||||||
(with-temp-file path
|
(with-temp-file path
|
||||||
(insert-file-contents path)
|
(insert-file-contents path)
|
||||||
(save-excursion (beginning-of-buffer)
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
(if (re-search-forward regexp nil t)
|
(if (re-search-forward regexp nil t)
|
||||||
(replace-match to-string nil nil)))))
|
(replace-match to-string nil nil)))))
|
||||||
|
|
||||||
|
@ -230,24 +232,24 @@ store your org-contacts."
|
||||||
(setq taglist (delete (match-string 1 tag) taglist)))
|
(setq taglist (delete (match-string 1 tag) taglist)))
|
||||||
(t
|
(t
|
||||||
(setq taglist (push tag taglist)))))
|
(setq taglist (push tag taglist)))))
|
||||||
|
|
||||||
(setq taglist (sort (delete-dups taglist) 'string<))
|
(setq taglist (sort (delete-dups taglist) 'string<))
|
||||||
(setq tagstr (mapconcat 'identity taglist sep))
|
(setq tagstr (mapconcat 'identity taglist sep))
|
||||||
|
|
||||||
(setq tagstr (replace-regexp-in-string "[\\&]" "\\\\\\&" tagstr))
|
(setq tagstr (replace-regexp-in-string "[\\&]" "\\\\\\&" tagstr))
|
||||||
(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
|
;; Add tags header just before the content
|
||||||
(mu4e~replace-first-line-matching
|
(mu4e~replace-first-line-matching
|
||||||
"^$" (concat header ": " tagstr "\n") path)
|
"^$" (concat header ": " tagstr "\n") path)
|
||||||
|
|
||||||
;; replaces keywords, restricted to the header
|
;; replaces keywords, restricted to the header
|
||||||
(mu4e~replace-first-line-matching
|
(mu4e~replace-first-line-matching
|
||||||
(concat header ":.*")
|
(concat header ":.*")
|
||||||
(concat header ": " tagstr)
|
(concat header ": " tagstr)
|
||||||
path))
|
path))
|
||||||
|
|
||||||
(mu4e-message (concat "tagging: " (mapconcat 'identity taglist ", ")))
|
(mu4e-message (concat "tagging: " (mapconcat 'identity taglist ", ")))
|
||||||
(mu4e-refresh-message path maildir)))
|
(mu4e-refresh-message path maildir)))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
Loading…
Reference in New Issue