From 2d79de5705e95dbaf6c76f40081872e0ebacbeb4 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 14 Nov 2015 01:29:57 +0200 Subject: [PATCH] [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh --- 28/8421db03f24447fb2ec413ae35eb5b469560e5 | 210 ++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 28/8421db03f24447fb2ec413ae35eb5b469560e5 diff --git a/28/8421db03f24447fb2ec413ae35eb5b469560e5 b/28/8421db03f24447fb2ec413ae35eb5b469560e5 new file mode 100644 index 000000000..3aef7ca8d --- /dev/null +++ b/28/8421db03f24447fb2ec413ae35eb5b469560e5 @@ -0,0 +1,210 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 6B38B6DE133A + for ; Fri, 13 Nov 2015 15:30:04 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.127 +X-Spam-Level: +X-Spam-Status: No, score=0.127 tagged_above=-999 required=5 tests=[AWL=0.667, + RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id ieVRxBwj3y13 for ; + Fri, 13 Nov 2015 15:30:01 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 9A4486DE12F3 + for ; Fri, 13 Nov 2015 15:30:00 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 717D21000C6; Sat, 14 Nov 2015 01:29:58 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Cc: tomi.ollila@iki.fi +Subject: [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh +Date: Sat, 14 Nov 2015 01:29:57 +0200 +Message-Id: <1447457397-11688-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.0.0 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 13 Nov 2015 23:30:04 -0000 + +devel/try-emacs-mua.sh provides an easy way to try and experiment with +the notmuch emacs client provided in emacs subdirectory of notmuch +source tree. + +User is required to choose whether to run emacs with -q, -Q or neither +-- and experienced ones may add other command line options, like +'-f notmuch'. + +With emaces older than 24.4 it is checked that none of the .elc files +in notmuch/emacs directory is older than their corresponding .el files +before running emacs. With newer emaces variable `load-prefer-newer' +is effective so having old .elcs do not matter. + +Last possibility for "error" is when emacs starts and loads notmuch +(by init file) before there is change to have notmuch/emacs directory +in load-path. This time the message is written to emacs' *scratch* buffer. + +If everything is OK, the *scratch* buffer is filled with some lisp code +which user can evaluate before running notmuch functions. +--- + +Version 3 (I guess) -- the discovery Mark made in +id:87si4bwrsu.fsf@qmul.ac.uk has been fixed (originally to perl code, +but now converted to shell) -- and changed to just recognize that there +are old .elc files -- and the check is done only for emacses < 24.4. +Now loading of "notmuch" is wrapped in (let ((load-prefer-newer t)) ...). + +I tried tricks to ensure that notmuch*.el files are (always) loaded, but +it either got too complicated (hacky, potentially fragile defadvices), or +I saw plenty of *.el.gz uncompressions happening (and recursion loop in +jka-compr before that)... + +There is one notably change to the previous one -- before loading notmuch +there is check whether it is already loaded; if it is there is no point +going further here. Thanks for this discovery goes to IRC debugging +section with (mark and) "pseudomyne". + + devel/try-emacs-mua.sh | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 117 insertions(+) + create mode 100755 devel/try-emacs-mua.sh + +diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh +new file mode 100755 +index 000000000000..e8406e3cb143 +--- /dev/null ++++ b/devel/try-emacs-mua.sh +@@ -0,0 +1,117 @@ ++#!/bin/sh ++ ++# This script offers an easy way to try and experiment with the ++# notmuch emacs client provided in notmuch/emacs directory. ++ ++set -eu ++ ++test $# -gt 0 || { ++ exec >&2 ++ echo ++ echo "Usage: $0 '' | q | Q [other-emacs-args]" ++ echo ++ printf " $0 %s\n" "'' starts emacs without either -q or -Q option" \ ++ "q starts emacs with -q" \ ++ "Q starts emacs with -Q" ++ echo ++ exit 1 ++} ++ ++case $1 in '') opt= ++ ;; q | -q) opt=-q ++ ;; Q | -Q) opt=-Q ++ ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1 ++esac ++shift ++ ++case $0 in ++ *\"*) echo "'$0' contain one or more '\"'s" >&2; exit 1 ;; ++ *\\*) echo "'$0' contain one or more '\\'s" >&2; exit 1 ;; ++ */*) d0=${0%/*} ;; ++ *) d0=. ++esac ++ ++pwd=$PWD ++cd "$d0"/.. ++nmd=$PWD ++emd=$PWD/emacs ++ ++test -f "$emd"/notmuch-lib.el || { ++ echo "Cannot find notmuch-emacs source directory" >&2 ++ exit 1 ++} ++ ++case `exec 2>&1 "${EMACS:-emacs}" -Q --batch -eval \ ++ '(message (if (boundp '\''load-prefer-newer) "<-yes->" "<-no->"))'` ++in (*'<-no->'*) ++ allnew=true ++ for elc in "$emd"/*.elc ++ do ++ test -f "$elc" || continue ++ if test "$elc" -ot "${elc%c}" ++ then ++ echo "'$elc' is older than '${elc%c}'" >&2 ++ allnew=false ++ fi ++ done ++ $allnew || { ++ exec >&2 ++ echo ++ echo "In directory '$emd' there are .elc files that are" ++ echo "older than their corresponding .el files." ++ echo "Please remove (or recompile) these older files and try again." ++ echo ++ exit 1 ++ } ++ unset allnew ++esac ++ ++if test -x "$nmd"/notmuch ++then ++ nmin=' ++To use accompanied notmuch binary from the same source, evaluate ++(setq exec-path (cons \"'"$nmd"'\" exec-path)) ++Note: Evaluating the above may be followed by unintended database ++upgrade and getting back to old version may require dump & restore. ++' ++else ++ nmin= ++fi ++ ++if test "$opt" = '-q' || test "$opt" = '-Q' ++then ++ qin=' ++If you want to load your .emacs startup file now, evaluate ++(load \"~/.emacs\") ++ ++If you want to use packages (e.g. company from elpa) evaluate ++(progn (require '\''package) (package-initialize)) ++' ++else ++ qin=' ++To view initialization time messages, evaluate ++(pop-to-buffer \"*Messages*\") ++' ++fi ++ ++cd "$pwd" ++ ++exec "${EMACS:-emacs}" $opt --debug-init -L "$emd" --eval ' ++(with-current-buffer "*scratch*" ++ (if (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 rerun \"'"$0"'\" with '"'q'"' to disable ++processing of the init file -- you can load it after emacs has started.\n\n") ++ (let ((load-prefer-newer t)) (load "notmuch" t)) ++ (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)) ++'"$nmin$qin"' ++To start notmuch (hello) screen, evaluate ++(notmuch-hello)")) (set-buffer-modified-p nil))' "$@" +-- +2.0.0 + -- 2.26.2