From: Tomi Ollila Date: Sun, 15 Nov 2015 10:07:20 +0000 (+0200) Subject: Re: [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a46851104f0f9ff1235ae1e25026432d92bf1f85;p=notmuch-archives.git Re: [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh --- diff --git a/90/33e3bcba587f162e933ebc13e762eb63d74668 b/90/33e3bcba587f162e933ebc13e762eb63d74668 new file mode 100644 index 000000000..46d58cfd7 --- /dev/null +++ b/90/33e3bcba587f162e933ebc13e762eb63d74668 @@ -0,0 +1,230 @@ +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 2954B6DE1016 + for ; Sun, 15 Nov 2015 02:07:18 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.721 +X-Spam-Level: +X-Spam-Status: No, score=0.721 tagged_above=-999 required=5 tests=[AWL=0.069, + SPF_NEUTRAL=0.652] 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 EdKX3kjVqP1B for ; + Sun, 15 Nov 2015 02:07:13 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 09F636DE0FC5 + for ; Sun, 15 Nov 2015 02:07:12 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id E0BD610008E + for ; Sun, 15 Nov 2015 12:07:20 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: Re: [PATCH v3] devel/emacs: add devel/try-emacs-mua.sh +In-Reply-To: <1447457397-11688-1-git-send-email-tomi.ollila@iki.fi> +References: <1447457397-11688-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.21+14~g053baf4 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Sun, 15 Nov 2015 10:07:18 -0000 + + +I am marking this obsolete as I got and idea if works is going to +be pretty cool... But if it doesn't work then we'll come back +to this version. + +Tomi + +On Sat, Nov 14 2015, Tomi Ollila wrote: + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> https://notmuchmail.org/mailman/listinfo/notmuch