[PATCH] Separated and added functions for emacses prior to 23.

Tomi Ollila tomi.ollila at iki.fi
Mon Aug 29 09:16:02 PDT 2011


A new file, emacs/notmuch-lib22.el was created and it is
required in emacs/notmuch-lib.el in case emacs-major-version
is less than 23. This file contains functions that were copied
from emacs 23.3 (verbatim).

The support for emacs versions less than 23 is far from complete;
many runtime errors occur when showing messages.
---

After doing this work and noticed the solution is not so simple
I chose alternative way and compiled emacs 23.3 for myself.

Anyway, this is good base if there is someone who *really* wants
to fix rest of the issues supporting emacses prior to version 23.
Alternative is to dump the support altogether...

The code in this patch compiles without warnings on emacs 23.3.

Tomi


 emacs/Makefile.local   |    1 +
 emacs/notmuch-lib.el   |   50 +++++++-----------------
 emacs/notmuch-lib22.el |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+), 36 deletions(-)
 create mode 100644 emacs/notmuch-lib22.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index ce0c3f0..3f787ee 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -3,6 +3,7 @@
 dir := emacs
 emacs_sources := \
 	$(dir)/notmuch-lib.el \
+	$(dir)/notmuch-lib22.el \
 	$(dir)/notmuch.el \
 	$(dir)/notmuch-query.el \
 	$(dir)/notmuch-show.el \
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index f93c957..63c14a4 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -21,6 +21,20 @@
 
 ;; This is an part of an emacs-based interface to the notmuch mail system.
 
+;;(if (< emacs-major-version 23)
+;;    (require 'notmuch-lib22))
+
+;; Instead of the above, outcommented code, this lets us avoid seeing the
+;; reference to notmuch-lib22 at all in compiled code when emacs is
+;; sufficiently new enough to supply them alone.
+(eval-when-compile
+  (if (< emacs-major-version 23)
+      (defmacro require-lib22-prior-to-23 ()
+	`(require 'notmuch-lib22))
+    (defmacro require-lib22-prior-to-23 () nil)))
+
+(require-lib22-prior-to-23)
+
 (defvar notmuch-command "notmuch"
   "Command to run the notmuch binary.")
 
@@ -129,42 +143,6 @@ within the current window."
       (setq list (cdr list)))
     (nreverse out)))
 
-; This lets us avoid compiling these replacement functions when emacs
-; is sufficiently new enough to supply them alone. We do the macro
-; treatment rather than just wrapping our defun calls in a when form
-; specifically so that the compiler never sees the code on new emacs,
-; (since the code is triggering warnings that we don't know how to get
-; rid of.
-;
-; A more clever macro here would accept a condition and a list of forms.
-(defmacro compile-on-emacs-prior-to-23 (form)
-  "Conditionally evaluate form only on emacs < emacs-23."
-  (list 'when (< emacs-major-version 23)
-	form))
-
-;; Compatibility functions for versions of emacs before emacs 23.
-;;
-;; Both 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
- (defun apply-partially (fun &rest args)
-   "Return a function that is a partial application of FUN to ARGS.
-ARGS is a list of the first N arguments to pass to FUN.
-The result is a new function which does the same as FUN, except that
-the first N arguments are fixed at the values with which this function
-was called."
-   (lexical-let ((fun fun) (args1 args))
-     (lambda (&rest args2) (apply fun (append args1 args2))))))
-
-(compile-on-emacs-prior-to-23
- (defun mouse-event-p (object)
-   "Return non-nil if OBJECT is a mouse click event."
-   (memq (event-basic-type object) '(mouse-1 mouse-2 mouse-3 mouse-movement))))
-
 ;; This variable is used only buffer local, but it needs to be
 ;; declared globally first to avoid compiler warnings.
 (defvar notmuch-show-process-crypto nil)
diff --git a/emacs/notmuch-lib22.el b/emacs/notmuch-lib22.el
new file mode 100644
index 0000000..80705a0
--- /dev/null
+++ b/emacs/notmuch-lib22.el
@@ -0,0 +1,98 @@
+;; Compatibility functions for versions of emacs before emacs 23.
+;;
+;; 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.
+
+;; In case there is need and someone is interested to support other [x]emacs versions.
+;; (if (< emacs-major-version 2y)
+;;    (require 'notmuch-lib2x))
+;;
+;;(eval-when-compile
+;;  (if (< emacs-major-version 2y)
+;;      (defmacro require-lib2x-prior-to-2y ()
+;;	`(require 'notmuch-lib22))
+;;    (defmacro require-lib2x-prior-to-2y () nil)))
+;;
+;;(require-lib2x-prior-to-2y)
+
+
+;;; simple.el --- basic editing commands for Emacs
+
+; --- emacs-23.3/lisp/simple.el:32:
+;; This is for lexical-let in apply-partially.
+(eval-when-compile (require 'cl))
+
+; --- emacs-23.3/lisp/simple.el:6538:
+;; Partial application of functions (similar to "currying").
+;; This function is here rather than in subr.el because it uses CL.
+(defun apply-partially (fun &rest args)
+  "Return a function that is a partial application of FUN to ARGS.
+ARGS is a list of the first N arguments to pass to FUN.
+The result is a new function which does the same as FUN, except that
+the first N arguments are fixed at the values with which this function
+was called."
+  (lexical-let ((fun fun) (args1 args))
+    (lambda (&rest args2) (apply fun (append args1 args2)))))
+
+
+;;; subr.el --- basic lisp subroutines for Emacs
+
+; --- emacs-23.3/lisp/subr.el:850:
+(defun mouse-event-p (object)
+  "Return non-nil if OBJECT is a mouse click event."
+  ;; is this really correct? maybe remove mouse-movement?
+  (memq (event-basic-type object) '(mouse-1 mouse-2 mouse-3 mouse-movement)))
+
+; --- emacs-23.3/lisp/subr.el:1737:
+(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)))))
+
+
+;;; goto-addr.el --- click to browse URL or to send to e-mail address
+
+;; Copyright (C) 1995, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+;; Author: Eric Ding <ericding at alum.mit.edu>
+
+; --- emacs-23.3/lisp/net/goto-addr.el:152:
+(defun goto-address-unfontify (start end)
+  "Remove `goto-address' fontification from the given region."
+  (dolist (overlay (overlays-in start end))
+    (if (overlay-get overlay 'goto-address)
+	(delete-overlay overlay))))
+
+; --- emacs-23.3/lisp/net/goto-addr.el:278:
+(define-minor-mode goto-address-mode
+  "Minor mode to buttonize URLs and e-mail addresses in the current buffer."
+  nil
+  ""
+  nil
+  (if goto-address-mode
+      (jit-lock-register #'goto-address-fontify-region)
+    (jit-lock-unregister #'goto-address-fontify-region)
+    (save-restriction
+      (widen)
+      (goto-address-unfontify (point-min) (point-max)))))
+
+
+;;
+(provide 'notmuch-lib22)
-- 
1.5.6.5



More information about the notmuch mailing list