From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kHbiB/WpsV+WSAAA0tVLHw (envelope-from ) for ; Sun, 15 Nov 2020 22:21:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wMCZA/WpsV8pBAAAbx9fmQ (envelope-from ) for ; Sun, 15 Nov 2020 22:21:41 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4761C9403AD for ; Sun, 15 Nov 2020 22:21:39 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CD744203D6; Sun, 15 Nov 2020 17:21:30 -0500 (EST) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by mail.notmuchmail.org (Postfix) with ESMTPS id F235320088 for ; Sun, 15 Nov 2020 17:21:26 -0500 (EST) Received: by mail-wr1-x42f.google.com with SMTP id p1so16703290wrf.12 for ; Sun, 15 Nov 2020 14:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dme-org.20150623.gappssmtp.com; s=20150623; h=to:subject:in-reply-to:references:from:date:message-id:mime-version; bh=Z1SdraDspTUK20upTVRMkZ2cyVXIoI3asFqOg7hpA1E=; b=T870os2KlCT+chsRrcIpnbxBqIFXibb1dL8l+FGHmzvtKJRsFSme5WcV2sZ1Q8iOJl dYLhdcdNSNCvK/0Vta+qfaH/fhfKNv7fJuU6tnmg65LlBzTVj7KPJkhn+oWEkmcw1Ce9 unAK3Z9nnCbqdjbJhKhVi0xmlRI8XV+7KTVt3/a5+TVwsawDUvG9Bjyai8mwRqtCdvOL aL2DdJiEN8zompmMeazUEFUhIciuHX58D+CICI7xAl8wucHj5jn7ipldtNnQPY0BzZEl dxCgjVkFnLrKplZbX1EPb18+3rUpcQTETZDvIFLZ8mgEbJ1jllkdc9bpGWyF98hKmC57 SJxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:in-reply-to:references:from:date :message-id:mime-version; bh=Z1SdraDspTUK20upTVRMkZ2cyVXIoI3asFqOg7hpA1E=; b=qYEfTMPIXCoY4tpMWmqvO8RtSEiS1TEWTUmaxMLBdJDrXuO/ZuitNMQ/fhIti4j7iJ nqnG3+F017Or8UR+qodq4QMnET8PAD0Lv0tSJHhl+/VyEKJQJZsaURDEdLgGZD3CMdKV Z7JBU3P5LKnEGnklkMZElsfUc/oJZ38/s8xysLIJU/vXPX3VPrmFb5bOGn6ChrUpeh2n cNtwZLcf1Wfa49dRxLeNO1WzkNBXrdUgUdL6Lpx7Nu6sKJ/tIBwOoGh8QgqyD/UKVyNf skECZHkGL25BbTxN6Jj9rfskdRH2rhCGp7GyKK6HiR8tA/IemXqCgScasM1Fa0hTzAsa OctQ== X-Gm-Message-State: AOAM530H1tvm+7vMhXs88rjXZMy643h1dBqDykLg4Yu3+uZM6pfg35h9 bKizcHRXBSx4+/qxAzW9IKcU0MlVn4mbMMj8 X-Google-Smtp-Source: ABdhPJy/fTSpDQ1xg3+q1GU6SWLAgQQeRJjzjMm2ABBedodDGt+9QcfSIsPx3+yccFnYMYmXX4NarA== X-Received: by 2002:a5d:5686:: with SMTP id f6mr15898600wrv.329.1605478885203; Sun, 15 Nov 2020 14:21:25 -0800 (PST) Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net. [2001:8b0:bb71:7140:64::1]) by smtp.gmail.com with ESMTPSA id l16sm19270539wrx.5.2020.11.15.14.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:21:24 -0800 (PST) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 82075e7c; Sun, 15 Nov 2020 22:21:23 +0000 (UTC) To: Jonas Bernoulli , notmuch@notmuchmail.org Subject: Re: [PATCH 27/27] emacs: various cosmetic improvements In-Reply-To: <20201108190311.1397-28-jonas@bernoul.li> References: <20201108190311.1397-1-jonas@bernoul.li> <20201108190311.1397-28-jonas@bernoul.li> X-HGTTG: zarquon From: David Edmondson Date: Sun, 15 Nov 2020 22:21:23 +0000 Message-ID: MIME-Version: 1.0 Message-ID-Hash: QABKQNKYFZ4ADKQWS6DADJGE4P5NTLDQ X-Message-ID-Hash: QABKQNKYFZ4ADKQWS6DADJGE4P5NTLDQ X-MailFrom: dme@dme.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=dme-org.20150623.gappssmtp.com header.s=20150623 header.b=T870os2K; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: -0.01 X-TUID: 7cMbxdsycobC On Sunday, 2020-11-08 at 20:03:11 +01, Jonas Bernoulli wrote: There were some places here where you capitalised comments (more generally, turned them into English prose) when they were moving for $reasons, and others where you left them alone. Was there a rationale for the different treatment? Reviewed-by: David Edmondson > --- > emacs/notmuch-address.el | 31 ++++++-------- > emacs/notmuch-hello.el | 28 +++++-------- > emacs/notmuch-lib.el | 38 +++++++++-------- > emacs/notmuch-mua.el | 10 ++--- > emacs/notmuch-tag.el | 2 +- > emacs/notmuch.el | 88 ++++++++++++++++++++-------------------- > 6 files changed, 91 insertions(+), 106 deletions(-) > > diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el > index 21d1d82f..0dedd5d5 100644 > --- a/emacs/notmuch-address.el > +++ b/emacs/notmuch-address.el > @@ -21,6 +21,8 @@ > > ;;; Code: > > +(eval-when-compile (require 'cl-lib)) > + > (require 'message) > (require 'notmuch-parser) > (require 'notmuch-lib) > @@ -154,15 +156,12 @@ (defcustom notmuch-address-use-company t > :group 'notmuch-address) > > (defun notmuch-address-setup () > - (let* ((setup-company (and notmuch-address-use-company > - (require 'company nil t))) > - (pair (cons notmuch-address-completion-headers-regexp > - #'notmuch-address-expand-name))) > - (when setup-company > - (notmuch-company-setup)) > - (unless (member pair message-completion-alist) > - (setq message-completion-alist > - (push pair message-completion-alist))))) > + (when (and notmuch-address-use-company > + (require 'company nil t)) > + (notmuch-company-setup)) > + (cl-pushnew (cons notmuch-address-completion-headers-regexp > + #'notmuch-address-expand-name) > + message-completion-alist :test #'equal)) > > (defun notmuch-address-toggle-internal-completion () > "Toggle use of internal completion for current buffer. > @@ -251,11 +250,8 @@ (defun notmuch-address-expand-name () > (t nil))) > > (defun notmuch-address-harvest-addr (result) > - (let ((name-addr (plist-get result :name-addr))) > - (puthash name-addr t notmuch-address-completions))) > - > -(defun notmuch-address-harvest-handle-result (obj) > - (notmuch-address-harvest-addr obj)) > + (puthash (plist-get result :name-addr) > + t notmuch-address-completions)) > > (defun notmuch-address-harvest-filter (proc string) > (when (buffer-live-p (process-buffer proc)) > @@ -264,7 +260,7 @@ (defun notmuch-address-harvest-filter (proc string) > (goto-char (point-max)) > (insert string)) > (notmuch-sexp-parse-partial-list > - 'notmuch-address-harvest-handle-result (process-buffer proc))))) > + 'notmuch-address-harvest-addr (process-buffer proc))))) > > (defvar notmuch-address-harvest-procs '(nil . nil) > "The currently running harvests. > @@ -375,7 +371,7 @@ (defun notmuch-address--load-address-hash () > (defun notmuch-address--save-address-hash () > (when notmuch-address-save-filename > (if (or (not (file-exists-p notmuch-address-save-filename)) > - ;; The file exists, check it is a file we saved > + ;; The file exists, check it is a file we saved. > (notmuch-address--get-address-hash)) > (with-temp-file notmuch-address-save-filename > (let ((save-plist > @@ -398,8 +394,7 @@ (defun notmuch-address-harvest-trigger () > nil nil > (lambda (proc event) > ;; If harvest fails, we want to try > - ;; again when the trigger is next > - ;; called > + ;; again when the trigger is next called. > (if (string= event "finished\n") > (progn > (notmuch-address--save-address-hash) > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el > index fa31694f..80af7544 100644 > --- a/emacs/notmuch-hello.el > +++ b/emacs/notmuch-hello.el > @@ -402,8 +402,7 @@ (defun notmuch-hello-add-saved-search (widget) > ;; If an existing saved search with this name exists, remove it. > (setq notmuch-saved-searches > (cl-loop for elem in notmuch-saved-searches > - if (not (equal name > - (notmuch-saved-search-get elem :name))) > + unless (equal name (notmuch-saved-search-get elem :name)) > collect elem)) > ;; Add the new one. > (customize-save-variable 'notmuch-saved-searches > @@ -446,18 +445,14 @@ (defun notmuch-hello-reflect (list ncols) > append (notmuch-hello-reflect-generate-row ncols nrows row list)))) > > (defun notmuch-hello-widget-search (widget &rest ignore) > - (cond > - ((eq (widget-get widget :notmuch-search-type) 'tree) > - (notmuch-tree (widget-get widget > - :notmuch-search-terms))) > - ((eq (widget-get widget :notmuch-search-type) 'unthreaded) > - (notmuch-unthreaded (widget-get widget > - :notmuch-search-terms))) > + (cl-case (widget-get widget :notmuch-search-type) > + (tree > + (notmuch-tree (widget-get widget :notmuch-search-terms))) > + (unthreaded > + (notmuch-unthreaded (widget-get widget :notmuch-search-terms))) > (t > - (notmuch-search (widget-get widget > - :notmuch-search-terms) > - (widget-get widget > - :notmuch-search-oldest-first))))) > + (notmuch-search (widget-get widget :notmuch-search-terms) > + (widget-get widget :notmuch-search-oldest-first))))) > > (defun notmuch-saved-search-count (search) > (car (process-lines notmuch-command "count" search))) > @@ -689,9 +684,7 @@ (define-derived-mode notmuch-hello-mode fundamental-mode "notmuch-hello" > Complete list of currently available key bindings: > > \\{notmuch-hello-mode-map}" > - (setq notmuch-buffer-refresh-function #'notmuch-hello-update) > - ;;(setq buffer-read-only t) > - ) > + (setq notmuch-buffer-refresh-function #'notmuch-hello-update)) > > (defun notmuch-hello-generate-tag-alist (&optional hide-tags) > "Return an alist from tags to queries to display in the all-tags section." > @@ -775,8 +768,7 @@ (defun notmuch-hello-insert-search () > ;; instead of a space to make `show-trailing-whitespace' > ;; happy, i.e. avoid it marking the whole line as trailing > ;; spaces. > - (widget-insert ".") > - (put-text-property (1- (point)) (point) 'invisible t) > + (widget-insert (propertize "." 'invisible t)) > (widget-insert "\n")) > > (defun notmuch-hello-insert-recent-searches () > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > index e23999ad..aa48b949 100644 > --- a/emacs/notmuch-lib.el > +++ b/emacs/notmuch-lib.el > @@ -186,8 +186,8 @@ (defun notmuch-command-to-string (&rest args) > > Otherwise the output will be returned." > (with-temp-buffer > - (let* ((status (apply #'call-process notmuch-command nil t nil args)) > - (output (buffer-string))) > + (let ((status (apply #'call-process notmuch-command nil t nil args)) > + (output (buffer-string))) > (notmuch-check-exit-status status (cons notmuch-command args) output) > output))) > > @@ -239,8 +239,9 @@ (defun notmuch-config-get (item) > (let* ((val (notmuch-command-to-string "config" "get" item)) > (len (length val))) > ;; Trim off the trailing newline (if the value is empty or not > - ;; configured, there will be no newline) > - (if (and (> len 0) (= (aref val (- len 1)) ?\n)) > + ;; configured, there will be no newline). > + (if (and (> len 0) > + (= (aref val (- len 1)) ?\n)) > (substring val 0 -1) > val))) > > @@ -403,9 +404,9 @@ (defun notmuch-help () > its prefixed behavior by setting the 'notmuch-prefix-doc property > of its command symbol." > (interactive) > - (let* ((mode major-mode) > - (doc (substitute-command-keys > - (notmuch-substitute-command-keys (documentation mode t))))) > + (let ((doc (substitute-command-keys > + (notmuch-substitute-command-keys > + (documentation major-mode t))))) > (with-current-buffer (generate-new-buffer "*notmuch-help*") > (insert doc) > (goto-char (point-min)) > @@ -467,8 +468,8 @@ (defun notmuch-refresh-all-buffers () > (notmuch-refresh-this-buffer)))))) > > (defun notmuch-prettify-subject (subject) > - ;; This function is used by `notmuch-search-process-filter' which > - ;; requires that we not disrupt its' matching state. > + ;; This function is used by `notmuch-search-process-filter', > + ;; which requires that we not disrupt its matching state. > (save-match-data > (if (and subject > (string-match "^[ \t]*$" subject)) > @@ -525,13 +526,12 @@ (defun notmuch-common-do-stash (text) > ;; > > (defun notmuch-plist-delete (plist property) > - (let* ((xplist (cons nil plist)) > - (pred xplist)) > - (while (cdr pred) > - (when (eq (cadr pred) property) > - (setcdr pred (cdddr pred))) > - (setq pred (cddr pred))) > - (cdr xplist))) > + (let (p) > + (while plist > + (unless (eq property (car plist)) > + (setq p (plist-put p (car plist) (cadr plist)))) > + (setq plist (cddr plist))) > + p)) > > (defun notmuch-match-content-type (t1 t2) > "Return t if t1 and t2 are matching content types, taking wildcards into account." > @@ -540,8 +540,10 @@ (defun notmuch-match-content-type (t1 t2) > (if (or (string= (cadr st1) "*") > (string= (cadr st2) "*")) > ;; Comparison of content types should be case insensitive. > - (string= (downcase (car st1)) (downcase (car st2))) > - (string= (downcase t1) (downcase t2))))) > + (string= (downcase (car st1)) > + (downcase (car st2))) > + (string= (downcase t1) > + (downcase t2))))) > > (defvar notmuch-multipart/alternative-discouraged > '(;; Avoid HTML parts. > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el > index f9843546..8501e294 100644 > --- a/emacs/notmuch-mua.el > +++ b/emacs/notmuch-mua.el > @@ -347,12 +347,10 @@ (defun notmuch-mua-pop-to-buffer (name switch-function) > (select-window window)) > (funcall switch-function buffer) > (set-buffer buffer)) > - (when (and (buffer-modified-p) > - (not (prog1 > - (y-or-n-p > - "Message already being composed; erase? ") > - (message nil)))) > - (error "Message being composed"))) > + (when (buffer-modified-p) > + (if (y-or-n-p "Message already being composed; erase? ") > + (message nil) > + (error "Message being composed")))) > (funcall switch-function name) > (set-buffer name)) > (erase-buffer) > diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el > index 925de78c..75e864a4 100644 > --- a/emacs/notmuch-tag.el > +++ b/emacs/notmuch-tag.el > @@ -472,7 +472,7 @@ (defun notmuch-tag (query tag-changes) > tag-changes) > (unless query > (error "Nothing to tag!")) > - (unless (null tag-changes) > + (when tag-changes > (run-hooks 'notmuch-before-tag-hook) > (if (<= (length query) notmuch-tag-argument-limit) > (apply 'notmuch-call-notmuch-process "tag" > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index b221be05..8157bbf4 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -169,7 +169,7 @@ (defvar notmuch-search-mode-map > (let ((map (make-sparse-keymap))) > (set-keymap-parent map notmuch-common-keymap) > (define-key map "x" 'notmuch-bury-or-kill-this-buffer) > - (define-key map (kbd "") 'notmuch-search-scroll-down) > + (define-key map (kbd "DEL") 'notmuch-search-scroll-down) > (define-key map "b" 'notmuch-search-scroll-down) > (define-key map " " 'notmuch-search-scroll-up) > (define-key map "<" 'notmuch-search-first-thread) > @@ -923,40 +923,39 @@ (defun notmuch-read-query (prompt) > "Read a notmuch-query from the minibuffer with completion. > > PROMPT is the string to prompt with." > - (let* > - ((all-tags > - (mapcar (lambda (tag) (notmuch-escape-boolean-term tag)) > - (process-lines notmuch-command "search" "--output=tags" "*"))) > - (completions > - (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:" > - "subject:" "attachment:") > - (mapcar (lambda (tag) (concat "tag:" tag)) all-tags) > - (mapcar (lambda (tag) (concat "is:" tag)) all-tags) > - (mapcar (lambda (mimetype) (concat "mimetype:" mimetype)) > - (mailcap-mime-types))))) > - (let ((keymap (copy-keymap minibuffer-local-map)) > - (current-query (cl-case major-mode > - (notmuch-search-mode (notmuch-search-get-query)) > - (notmuch-show-mode (notmuch-show-get-query)) > - (notmuch-tree-mode (notmuch-tree-get-query)))) > - (minibuffer-completion-table > - (completion-table-dynamic > - (lambda (string) > - ;; generate a list of possible completions for the current input > - (cond > - ;; this ugly regexp is used to get the last word of the input > - ;; possibly preceded by a '(' > - ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string) > - (mapcar (lambda (compl) > - (concat (match-string-no-properties 1 string) compl)) > - (all-completions (match-string-no-properties 2 string) > - completions))) > - (t (list string))))))) > - ;; this was simpler than convincing completing-read to accept spaces: > - (define-key keymap (kbd "TAB") 'minibuffer-complete) > - (let ((history-delete-duplicates t)) > - (read-from-minibuffer prompt nil keymap nil > - 'notmuch-search-history current-query nil))))) > + (let* ((all-tags > + (mapcar (lambda (tag) (notmuch-escape-boolean-term tag)) > + (process-lines notmuch-command "search" "--output=tags" "*"))) > + (completions > + (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:" > + "subject:" "attachment:") > + (mapcar (lambda (tag) (concat "tag:" tag)) all-tags) > + (mapcar (lambda (tag) (concat "is:" tag)) all-tags) > + (mapcar (lambda (mimetype) (concat "mimetype:" mimetype)) > + (mailcap-mime-types)))) > + (keymap (copy-keymap minibuffer-local-map)) > + (current-query (cl-case major-mode > + (notmuch-search-mode (notmuch-search-get-query)) > + (notmuch-show-mode (notmuch-show-get-query)) > + (notmuch-tree-mode (notmuch-tree-get-query)))) > + (minibuffer-completion-table > + (completion-table-dynamic > + (lambda (string) > + ;; generate a list of possible completions for the current input > + (cond > + ;; this ugly regexp is used to get the last word of the input > + ;; possibly preceded by a '(' > + ((string-match "\\(^\\|.* (?\\)\\([^ ]*\\)$" string) > + (mapcar (lambda (compl) > + (concat (match-string-no-properties 1 string) compl)) > + (all-completions (match-string-no-properties 2 string) > + completions))) > + (t (list string))))))) > + ;; This was simpler than convincing completing-read to accept spaces: > + (define-key keymap (kbd "TAB") 'minibuffer-complete) > + (let ((history-delete-duplicates t)) > + (read-from-minibuffer prompt nil keymap nil > + 'notmuch-search-history current-query nil)))) > > (defun notmuch-search-get-query () > "Return the current query in this search buffer." > @@ -1006,10 +1005,9 @@ (defun notmuch-search (&optional query oldest-first target-thread target-line no > (setq notmuch-search-target-thread target-thread) > (setq notmuch-search-target-line target-line) > (notmuch-tag-clear-cache) > - (let ((proc (get-buffer-process (current-buffer))) > - (inhibit-read-only t)) > - (when proc > - (error "notmuch search process already running for query `%s'" query)) > + (when (get-buffer-process buffer) > + (error "notmuch search process already running for query `%s'" query)) > + (let ((inhibit-read-only t)) > (erase-buffer) > (goto-char (point-min)) > (save-excursion > @@ -1019,12 +1017,12 @@ (defun notmuch-search (&optional query oldest-first target-thread target-line no > (if oldest-first > "--sort=oldest-first" > "--sort=newest-first") > - query)) > - ;; Use a scratch buffer to accumulate partial output. > - ;; This buffer will be killed by the sentinel, which > - ;; should be called no matter how the process dies. > - (parse-buf (generate-new-buffer " *notmuch search parse*"))) > - (process-put proc 'parse-buf parse-buf) > + query))) > + ;; Use a scratch buffer to accumulate partial output. > + ;; This buffer will be killed by the sentinel, which > + ;; should be called no matter how the process dies. > + (process-put proc 'parse-buf > + (generate-new-buffer " *notmuch search parse*")) > (set-process-filter proc 'notmuch-search-process-filter) > (set-process-query-on-exit-flag proc nil)))) > (run-hooks 'notmuch-search-hook))) > -- > 2.29.1 > _______________________________________________ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-leave@notmuchmail.org dme. -- I just bite it, it's for the look I don't light it.