Re: [PATCH] notmuch-emacs-mua: do not create a frame by default with --client
[notmuch-archives.git] / 5d / 7e14b00e496860fe2d907f5ca42f2bc459a1a2
1 Return-Path: <tomi.ollila@iki.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 25915431FC2\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Mar 2015 13:35:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id N711mikhzvfh for <notmuch@notmuchmail.org>;\r
16         Sun, 22 Mar 2015 13:35:37 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 33A31431FBF\r
19         for <notmuch@notmuchmail.org>; Sun, 22 Mar 2015 13:35:37 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 6D6A7100086;\r
22         Sun, 22 Mar 2015 22:35:12 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH] notmuch-emacs-mua: do not create a frame by default\r
26         with    --client\r
27 In-Reply-To: <1427055269-4742-1-git-send-email-jani@nikula.org>\r
28 References: <1427055269-4742-1-git-send-email-jani@nikula.org>\r
29 User-Agent: Notmuch/0.19+92~g61c04e8 (http://notmuchmail.org) Emacs/24.3.1\r
30         (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Sun, 22 Mar 2015 22:35:12 +0200\r
35 Message-ID: <m28ueog48v.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sun, 22 Mar 2015 20:35:41 -0000\r
51 \r
52 On Sun, Mar 22 2015, Jani Nikula <jani@nikula.org> wrote:\r
53 \r
54 > Make the default behaviour for --client the same as emacsclient\r
55 > default: do not create a new frame. Add a new option --create-frame,\r
56 > passing the same option to emacsclient to create a frame.\r
57 >\r
58 > ---\r
59 \r
60 Changes LGTM.\r
61 \r
62 Tomi\r
63 \r
64 >\r
65 > With this, 'notmuch-emacs-mua --client' does what I want, which was\r
66 > not possible with any combination of options before. Please see if you\r
67 > can still do what you want!\r
68 > ---\r
69 >  doc/man1/notmuch-emacs-mua.rst | 14 +++++++++-----\r
70 >  notmuch-emacs-mua              | 29 ++++++++++++++++++++---------\r
71 >  2 files changed, 29 insertions(+), 14 deletions(-)\r
72 >\r
73 > diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst\r
74 > index 36b51cdc3b18..e39d9e5fba1f 100644\r
75 > --- a/doc/man1/notmuch-emacs-mua.rst\r
76 > +++ b/doc/man1/notmuch-emacs-mua.rst\r
77 > @@ -18,10 +18,6 @@ Supported options for **notmuch-emacs-mua** include\r
78 >      ``-h, --help``\r
79 >          Display help.\r
80 >  \r
81 > -    ``--client``\r
82 > -        Use emacsclient, rather than emacs. This will start\r
83 > -        an emacs daemon process if necessary.\r
84 > -\r
85 >      ``-s, --subject=``\ <subject>\r
86 >          Specify the subject of the message.\r
87 >  \r
88 > @@ -38,7 +34,15 @@ Supported options for **notmuch-emacs-mua** include\r
89 >          Specify a file to include into the body of the message.\r
90 >  \r
91 >      ``--no-window-system``\r
92 > -        Even if a window system is available, use the current terminal\r
93 > +        Even if a window system is available, use the current terminal.\r
94 > +\r
95 > +    ``--client``\r
96 > +        Use **emacsclient**, rather than **emacs**. This will start\r
97 > +        an emacs daemon process if necessary.\r
98 > +\r
99 > +    ``--create-frame``\r
100 > +         When --client is specified, create a new frame instead of trying\r
101 > +         to use the current Emacs frame.\r
102 >  \r
103 >      ``--print``\r
104 >          Output the resulting elisp to stdout instead of evaluating it.\r
105 > diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua\r
106 > index 13f67bee4417..68c2643df581 100755\r
107 > --- a/notmuch-emacs-mua\r
108 > +++ b/notmuch-emacs-mua\r
109 > @@ -31,12 +31,12 @@ EMACS=${EMACS-emacs}\r
110 >  EMACSCLIENT=${EMACSCLIENT-emacsclient}\r
111 >  \r
112 >  PRINT_ONLY=\r
113 > +NO_WINDOW=\r
114 >  USE_EMACSCLIENT=\r
115 > -CLIENT_TYPE="-c"\r
116 > +CREATE_FRAME=\r
117 >  \r
118 >  # The crux of it all: construct an elisp progn and eval it.\r
119 >  ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"\r
120 > -ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
121 >  \r
122 >  # Short options compatible with mutt(1).\r
123 >  while getopts :s:c:b:i:h opt; do\r
124 > @@ -60,7 +60,7 @@ while getopts :s:c:b:i:h opt; do\r
125 >                   opt=${opt%%=*}\r
126 >                   ;;\r
127 >               # Long options without arguments.\r
128 > -             --help|--print|--no-window-system|--client)\r
129 > +             --help|--print|--no-window-system|--client|--create-frame)\r
130 >                   ;;\r
131 >               *)\r
132 >                   echo "$0: unknown long option ${opt}, or argument mismatch." >&2\r
133 > @@ -80,9 +80,6 @@ while getopts :s:c:b:i:h opt; do\r
134 >       --help|h)\r
135 >           exec man notmuch-emacs-mua\r
136 >           ;;\r
137 > -     --client)\r
138 > -         USE_EMACSCLIENT="yes"\r
139 > -         ;;\r
140 >       --subject|s)\r
141 >           ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
142 >           ;;\r
143 > @@ -102,7 +99,13 @@ while getopts :s:c:b:i:h opt; do\r
144 >           PRINT_ONLY=1\r
145 >           ;;\r
146 >       --no-window-system)\r
147 > -         CLIENT_TYPE="-t"\r
148 > +         NO_WINDOW="-nw"\r
149 > +         ;;\r
150 > +     --client)\r
151 > +         USE_EMACSCLIENT="yes"\r
152 > +         ;;\r
153 > +     --create-frame)\r
154 > +         CREATE_FRAME="--create-frame"\r
155 >           ;;\r
156 >       *)\r
157 >           # We should never end up here.\r
158 > @@ -121,6 +124,14 @@ for arg; do\r
159 >      ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
160 >  done\r
161 >  \r
162 > +# If reusing a frame in emacsclient, don't kill the buffer.\r
163 > +if [ -z "$CREATE_FRAME" ]; then\r
164 > +    ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
165 > +elif [ -z "$USE_EMACSCLIENT" ]; then\r
166 > +    echo "$0: --create-frame is only applicable with --client." >&2\r
167 > +    exit 1\r
168 > +fi\r
169 > +\r
170 >  # End progn.\r
171 >  ELISP="${ELISP})"\r
172 >  \r
173 > @@ -131,7 +142,7 @@ fi\r
174 >  \r
175 >  if [ -n "$USE_EMACSCLIENT" ]; then\r
176 >      # Evaluate the progn.\r
177 > -    exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"\r
178 > +    exec ${EMACSCLIENT} ${CREATE_FRAME} ${NO_WINDOW} -a '' --eval "${ELISP}"\r
179 >  else\r
180 > -    exec ${EMACS} --eval "${ELISP}"\r
181 > +    exec ${EMACS} ${NO_WINDOW} --eval "${ELISP}"\r
182 >  fi\r
183 > -- \r
184 > 2.1.4\r
185 >\r
186 > _______________________________________________\r
187 > notmuch mailing list\r
188 > notmuch@notmuchmail.org\r
189 > http://notmuchmail.org/mailman/listinfo/notmuch\r