[PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness.

Austin Clements amdragon at MIT.EDU
Mon Jan 30 15:46:55 PST 2012


LGTM.  One comment that you can take or leave.

Quoth David Edmondson on Jan 30 at 10:16 am:
> There's no need to call `truncate-string-to-width' twice in this code
> path.
> ---
>  emacs/notmuch.el |   22 ++++++++++------------
>  1 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 72f78ed..d4d6904 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -469,18 +469,16 @@ Complete list of currently available key bindings:
>    (let ((thread-id (notmuch-search-find-thread-id))
>  	(subject (notmuch-search-find-subject)))
>      (if (> (length thread-id) 0)
> -	(notmuch-show thread-id
> -		      (current-buffer)
> -		      notmuch-search-query-string
> -		      ;; name the buffer based on notmuch-search-find-subject
> -		      (if (string-match "^[ \t]*$" subject)
> -			  "[No Subject]"
> -			(truncate-string-to-width
> -			 (concat "*"
> -				 (truncate-string-to-width subject 32 nil nil t)
> -				 "*")
> -			 32 nil nil t))
> -		      crypto-switch)
> +	(progn
> +	  (if (string-match "^[ \t]*$" subject)
> +	      (setq subject "[No Subject]"))
> +
> +	  (notmuch-show thread-id
> +			(current-buffer)
> +			notmuch-search-query-string
> +			;; Name the buffer based on the subject.
> +			(concat "*" (truncate-string-to-width subject 30 nil nil t) "*")
> +			crypto-switch))
>        (message "End of search results."))))

Should this instead be an `error'?  It that makes sense, it would also
simplify the code, since you could

(if (= (length thread-id) 0)
    (error "End of search results."))
<current progn body>

>  
>  (defun notmuch-search-reply-to-thread (&optional prompt-for-sender)


More information about the notmuch mailing list