unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 1f916d2806f9f4476aff808ce56e8b7a033d4f5d 5690 bytes (raw)
name: devel/try-emacs-mua 	 # 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 
#!/bin/sh
:; set -x; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit
;;
;; Try the notmuch emacs client located in ../notmuch/emacs directory
;;
;; Run this without arguments; emacs window opens with some usage information
;;
;; Authors: Tomi Ollila <tomi.ollila@iki.fi>
;;
;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point...
;;
;; Licence: GPLv3+
;;

(message "Starting '%s'" load-file-name)

(set-buffer "*scratch*")

(setq initial-buffer-choice t) ;; *scratch* buffer

(when (featurep 'notmuch)
  (insert "
Notmuch has been loaded to this emacs (during processing of the init file)
which means it is (most probably) loaded from different source than expected.

Please run \"" (file-name-nondirectory load-file-name)
"\" with '-q' (or '-Q') as an argument, to disable
processing of the init file -- you can load it after emacs has started\n
exit emacs (y or n)? ")
  (if (y-or-n-p "exit emacs")
      (kill-emacs)
    (error "Stopped reading %s" load-file-name)))

(let ((pdir (file-name-directory
	     (directory-file-name (file-name-directory load-file-name)))))
  (unless (file-exists-p (concat pdir "emacs/notmuch-lib.el"))
    (insert "Cannot find notmuch-emacs source directory
while looking at: " pdir "emacs\n\nexit emacs (y or n)? ")
    (if (y-or-n-p "exit emacs")
	(kill-emacs)
      (error "Stopped reading %s" load-file-name)))
  (setq try-notmuch-source-directory (directory-file-name pdir))
  (setq try-notmuch-emacs-directory (concat pdir "emacs/"))
  (setq load-path (cons try-notmuch-emacs-directory load-path)))

;; for logging, debugging and load tracing (broke on emacs 24.5.1 :O)
;;(defadvice file-truename (before before-file-truename activate)
;;;;  (message "file-truename: '%s' '%s' '%s'" filename counter prev-dirs))
;;  (unless counter
;;    (message "file-truename: %s" filename)))

;; they say advice doesn't work for primitives (functions from c source)
;; well, these 'before' advice works for emacs 23.1 - 24.5 (at least)
;; ...and for our purposes 24.3 is enough (there is no load-prefer-newer there)
;; note also that the old, "obsolete" defadvice mechanism was used, but that
;; is the only one available for emacs 23 and 24 up to 24.3.

(if (boundp 'load-prefer-newer)
    (defadvice require (before before-require activate)
      (unless (featurep feature)
	(message "require: %s" feature)))
  ;; else: special require "short-circuit"; after load feature is provided...
  ;; ... in notmuch sources we always use require and there are no loops
  (defadvice require (before before-require activate)
    (unless (featurep feature)
      (message "require: %s" feature)
      (let ((name (symbol-name feature)))
	(if (and (string-match "^notmuch" name)
		 (file-newer-than-file-p
		  (concat try-notmuch-emacs-directory name ".el")
		  (concat try-notmuch-emacs-directory name ".elc")))
	    (load (concat try-notmuch-emacs-directory name ".el") nil nil t t)
	  )))))

(insert "Found notmuch emacs client in " try-notmuch-emacs-directory "\n")

(condition-case err
;; "opportunistic" load-prefer-newer -- will be effective since emacs 24.4
    (let ((load-prefer-newer t)
	  (force-load-messages t))
      (require 'notmuch))
  ;; specifying `debug' here lets the debugger run
  ;; if `debug-on-error' is non-nil.
  ((debug error)
   (progn
     (insert "\nLoading notmuch failed: " (error-message-string err) "\n")
     (insert "See *Messages* buffer for more information.\n")
     (error "Stopped reading %s" load-file-name))))

(insert "
Go to the end of the following lines and type C-x C-e to evaluate
(or C-j which is shorter but inserts evaluation results into buffer)

To \"disable\" mail sending, evaluate
* (setq message-send-mail-function (lambda () t))
")

(if (file-exists-p (concat try-notmuch-source-directory "/notmuch"))
    (insert "
To use accompanied notmuch binary from the same source, evaluate
* (setq exec-path (cons \"" try-notmuch-source-directory  "\" exec-path))
Note: Evaluating the above may be followed by unintended database
upgrade and getting back to old version may require dump & restore.
"))

(if init-file-user ;; nil, if '-q' or '-Q' is given, but no '-u' 'USER'
    (insert "
Your init file was processed during emacs startup. If you want to test
notmuch emacs mail client without your emacs init file interfering, Run\n\""
(file-name-nondirectory load-file-name) "\" with '-q' (or '-Q') as an argument.
")
  (let ((init-file-name))
    ;; determining init file name in startup.el/command-line is too complicated
    ;; to be duplicated here; these 3 file names covers most of the users
    (mapc (lambda (fn) (if (file-exists-p fn) (setq init-file-name fn)))
	  '("~/.emacs.d/init.el" "~/.emacs" "~/.emacs.el"))
    (if init-file-name
	(insert "
If you want to load your emacs init file now, evaluate
* (load \"" init-file-name "\")
")))
  (insert "
If you want to use packages (e.g. company from elpa) evaluate
* (progn (require 'package) (package-initialize))
"))

(insert "
To start notmuch (hello) screen, evaluate
* (notmuch-hello)")

(setq try-emacs-pop-messages-buffers nil)

(add-hook 'command-line-functions
	  (lambda ()
	    (unless try-emacs-pop-messages-buffers (message "%s" ""))
	    (message "*** Ignoring arg '%s'" argi)
	    (setq try-emacs-pop-messages-buffers t)))

(add-hook 'emacs-startup-hook
	  (lambda ()
	    (when try-emacs-pop-messages-buffers
	      (message "%s" "")
	      (message "Press 'q' to hide this window")
	      (pop-to-buffer "*Messages*"))
	    (set-buffer "*scratch*")
	    (lisp-interaction-mode)
	    (goto-char (point-min))
	    (forward-line)
	    (set-buffer-modified-p nil)))

;; Local Variables:
;; mode: emacs-lisp
;; End:

debug log:

solving 1f916d2806f9 ...
found 1f916d2806f9 in https://yhetil.org/notmuch/1450610032-23776-1-git-send-email-tomi.ollila@iki.fi/

applying [1/1] https://yhetil.org/notmuch/1450610032-23776-1-git-send-email-tomi.ollila@iki.fi/
diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua
new file mode 100755
index 000000000000..1f916d2806f9

Checking patch devel/try-emacs-mua...
Applied patch devel/try-emacs-mua cleanly.

index at:
100755 1f916d2806f9f4476aff808ce56e8b7a033d4f5d	devel/try-emacs-mua

(*) 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).