PATCH: (more) compability with emacs 22

Tomi Ollila tomi.ollila at nixu.com
Tue Aug 16 02:31:18 PDT 2011


Hi

Currently, notmuch-lib.el does not have enough emacs < 23
compability functions.

This patch makes notmuch better compatible with emacs 22:

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index f93c957..d6b4108 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -144,12 +144,35 @@ within the current window."
 
 ;; Compatibility functions for versions of emacs before emacs 23.
 ;;
-;; Both functions here were copied from emacs 23 with the following copyright:
+;; All functions here were copied from emacs 23 with the following copyright:
 ;;
 ;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
 ;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 ;;
 ;; and under the GPL version 3 (or later) exactly as notmuch itself.
+
+(compile-on-emacs-prior-to-23
+ (load "cl-macs"))
+
+(compile-on-emacs-prior-to-23
+ (defun process-lines (program &rest args)
+   "Execute PROGRAM with ARGS, returning its output as a list of lines.
+Signal an error if the program returns with a non-zero exit status."
+   (with-temp-buffer
+     (let ((status (apply 'call-process program nil (current-buffer) nil args)))
+       (unless (eq status 0)
+	 (error "%s exited with status %s" program status))
+       (goto-char (point-min))
+       (let (lines)
+	 (while (not (eobp))
+	   (setq lines (cons (buffer-substring-no-properties
+			      (line-beginning-position)
+			      (line-end-position))
+			     lines))
+	   (forward-line 1))
+	 (nreverse lines))))))
+
+
 (compile-on-emacs-prior-to-23
  (defun apply-partially (fun &rest args)
    "Return a function that is a partial application of FUN to ARGS.

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

I personally would like to move emacs < 23 functionality to separate file,
like 'notmuch-lib22.el' and then write the following to notmuch-lib.el:

(when (< emacs-major-version 23) (require 'notmuch-lib22))

Tomi


More information about the notmuch mailing list