[PATCH 0/3] Fix some error handling in notmuch new
[notmuch-archives.git] / 8a / f0260bc01429d53922eec87fa0d188e60d0157
1 Return-Path: <too@guru.guru-group.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 A060A429E28\r
6         for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 01:04:24 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 ACkJCM+XXJaK for <notmuch@notmuchmail.org>;\r
16         Mon, 16 Jan 2012 01:04:23 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 7A2A8429E26\r
19         for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 01:04:23 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 8A7FD68057; Mon, 16 Jan 2012 11:04:27 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: <notmuch@notmuchmail.org>\r
24 Subject: [PATCH 3/3] RFC: batch-tools.el\r
25 Date: Mon, 16 Jan 2012 11:04:16 +0200\r
26 Message-Id: <1326704656-26102-3-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.7.6.1\r
28 In-Reply-To: <1326704656-26102-1-git-send-email-tomi.ollila@iki.fi>\r
29 References: <cun7h0v7ete.fsf@hotblack-desiato.hh.sledj.net>\r
30         <1326704656-26102-1-git-send-email-tomi.ollila@iki.fi>\r
31 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Mon, 16 Jan 2012 09:04:24 -0000\r
45 \r
46 ---\r
47 \r
48 emacs -q -batch -l ../contrib/batch-tools.el -f batch-whitespace-cleanup \\r
49         with-indent *.el\r
50 \r
51 was used to produce previous patch\r
52 \r
53  emacs/batch-tools.el |   37 +++++++++++++++++++++++++++++++++++++\r
54  1 files changed, 37 insertions(+), 0 deletions(-)\r
55  create mode 100644 emacs/batch-tools.el\r
56 \r
57 diff --git a/emacs/batch-tools.el b/emacs/batch-tools.el\r
58 new file mode 100644\r
59 index 0000000..e83f825\r
60 --- /dev/null\r
61 +++ b/contrib/batch-tools.el\r
62 @@ -0,0 +1,37 @@\r
63 +;;\r
64 +;; Use this code to clean whitespace in (and optionally reindent) files\r
65 +;;\r
66 +;; Usage: emacs -q -batch -l batch-tools.el \\r
67 +;;     -f batch-whitespace-cleanup [with-indent] files...\r
68 +\r
69 +;; Borrows code fron batch-byte-compile. License: GPL3+\r
70 +\r
71 +(defun batch-whitespace-cleanup ()\r
72 +  "Run 'whitespace-cleanup' on the files remaining on the command line.\r
73 +If first arg is 'with-indent' do indent-region over the whole file too.\r
74 +Use this from the command line, with `-batch';\r
75 +it won't work in an interactive Emacs."\r
76 +  ;; command-line-args-left is what is left of the command line (from startup.el)\r
77 +  ;;  (defvar command-line-args-left)       ;Avoid 'free variable' warning\r
78 +  (if (not noninteractive)\r
79 +      (error "'batch-whitespace-cleanup' is to be used only with -batch"))\r
80 +  (let (filename do-indent)\r
81 +    (if (string= (car command-line-args-left) "with-indent")\r
82 +       (setq do-indent t\r
83 +             command-line-args-left (cdr command-line-args-left)))\r
84 +    (while command-line-args-left\r
85 +      (setq filename (expand-file-name (car command-line-args-left))\r
86 +           command-line-args-left (cdr command-line-args-left))\r
87 +      (if (file-directory-p filename)\r
88 +         ;; Directory as argument.\r
89 +         (message (concat "Skipping directory '" filename "'"))\r
90 +       ;; Specific file argument\r
91 +       (if (file-exists-p filename)\r
92 +           (with-temp-buffer\r
93 +             (message (concat "Loading file " filename "..."))\r
94 +             (find-file filename)\r
95 +             (whitespace-cleanup)\r
96 +             (if do-indent\r
97 +                 (indent-region (point-min) (point-max)))\r
98 +             (save-buffer))\r
99 +         (message (concat "Skipping nonexisteng file '" filename "'")))))))\r
100 -- \r
101 1.7.6.4\r
102 \r