unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 279c424f41d597b5243e312ec5fcdd49ff556606 4067 bytes (raw)
name: emacs/notmuch-hello.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
;; notmuch-hello.el --- welcome to notmuch, a frontend
;;
;; Copyright © David Edmondson
;;
;; This file is part of Notmuch.
;;
;; Notmuch is free software: you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Notmuch is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
;;
;; Authors: David Edmondson <dme@dme.org>

(require 'widget)

(require 'notmuch-lib)

(defvar notmuch-hello-searches-to-save 10)
(defvar notmuch-hello-search-width 60)

(defvar notmuch-hello-recent-searches nil)

(defun notmuch-hello-save-search (search)
  (if (not (memq search notmuch-hello-recent-searches))
      (push search notmuch-hello-recent-searches))
  (if (> (length notmuch-hello-recent-searches)
	 notmuch-hello-searches-to-save)
      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))

(defun notmuch-hello-trim (search)
  "Trim whitespace."
  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)
      (match-string 1 search)
    search))

(defun notmuch-hello-search (search)
  (let ((search (notmuch-hello-trim search)))
    (notmuch-hello-save-search search)
    (notmuch-search search)))

(defun notmuch-hello ()
  (interactive)

  (switch-to-buffer "*notmuch-hello*")
  (kill-all-local-variables)
  (let ((inhibit-read-only t))
    (erase-buffer))

  (let ((all (overlay-lists)))
    ;; Delete all the overlays.
    (mapcar 'delete-overlay (car all))
    (mapcar 'delete-overlay (cdr all)))

  (widget-insert "\nWelcome to notmuch.\n\n")
  (let ((start (point)))
    (widget-insert "Search: ")
    (widget-create 'editable-field
		   :size notmuch-hello-search-width
		   :action (lambda (widget &rest ignore)
			     (let ((search (widget-value widget)))
			       (notmuch-hello-search search))))
    (widget-insert "\n")
    (indent-rigidly start (point) 4))

  (when notmuch-hello-recent-searches
    (widget-insert "\nRecent searches:\n\n")
    (let ((start (point)))
      (mapcar '(lambda (search)
		 (widget-create 'editable-field
				:size notmuch-hello-search-width
				:action (lambda (widget &rest ignore)
					  (let ((search (widget-value widget)))
					    (notmuch-hello-search search)))
				search)
		 (widget-insert "\n"))
	      notmuch-hello-recent-searches)
      (indent-rigidly start (point) 4)))

  (widget-insert "\nFolders:\n\n")
  (let ((start (point)))
    (mapcar '(lambda (folder)
	       (let ((w (widget-create 'push-button
				       :notify (lambda (widget &rest ignore)
						 (notmuch-search (widget-get widget :notmuch-search-terms)))
				       "open")))
		 (widget-put w :notmuch-search-terms (cdr folder)))
	       (widget-insert (format " %6s %s\n" (notmuch-folder-count (cdr folder)) (car folder))))
	    notmuch-folders)
    (indent-rigidly start (point) 4))

  (widget-insert "\nAll tags:\n\n")
  (let ((start (point)))
    (mapcar '(lambda (tag)
	       (let ((w (widget-create 'push-button
				       :notify (lambda (widget &rest ignore)
						 (notmuch-search (widget-get widget :notmuch-search-terms)))
				       "open")))
		 (widget-put w :notmuch-search-terms (concat "tag:" tag)))
	       (widget-insert (format " %6s %s\n" (notmuch-folder-count
						   (concat "tag:" tag))
				      tag)))
	    (process-lines notmuch-command "search-tags"))
    (indent-rigidly start (point) 4))

  (use-local-map widget-keymap)
  (local-set-key "=" 'notmuch-hello)
  (local-set-key "q" '(lambda () (interactive) (kill-buffer (current-buffer))))

  (widget-setup)

  ;; Always put point inside the `search' widget, which we know is
  ;; first.
  (goto-char (point-min))
  (widget-forward 1))

debug log:

solving 279c424 ...
found 279c424 in https://yhetil.org/notmuch/87fx31j7w5.fsf@ut.hh.sledj.net/

applying [1/1] https://yhetil.org/notmuch/87fx31j7w5.fsf@ut.hh.sledj.net/
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
new file mode 100644
index 0000000..279c424

Checking patch emacs/notmuch-hello.el...
Applied patch emacs/notmuch-hello.el cleanly.

index at:
100644 279c424f41d597b5243e312ec5fcdd49ff556606	emacs/notmuch-hello.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).