branch: elpa/gnuplot
commit ae5e6283b036a2ffb0d70e854392468941e9fa39
Author: joddie <[email protected]>
Commit: joddie <[email protected]>

    Make context completion work on xemacs (21.4)
    
    - also fix an annoying bug with trying to load a non-compiled
      gnuplot-context
    
    - eval-after-load seems to work differently on xemacs (and old emacs
      versions?). workaround: gnuplot--run-after-load
    
    - remove an unnecessary (load ..) call from gnuplot-set-context-mode,
      since gnuplot-context is autoloaded
---
 gnuplot-context.el | 18 +++++++++++-------
 gnuplot.el         | 15 +++++++++++----
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/gnuplot-context.el b/gnuplot-context.el
index 6354e33..d125525 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -335,12 +335,12 @@ off. With no argument, toggle context-sensitive mode."
       (progn
         (when called-interactively-p
           (message "Gnuplot context-sensitive help & completion enabled."))
-        (eval-after-load 'gnuplot '(gnuplot--turn-on-context-sensitive-mode)))
+        (gnuplot--run-after-load 'gnuplot--turn-on-context-sensitive-mode))
 
     ;; Turn off
     (when called-interactively-p
       (message "Gnuplot context-sensitive help & completion disabled."))
-    (eval-after-load 'gnuplot '(gnuplot--turn-off-context-sensitive-mode))))
+    (gnuplot--run-after-load 'gnuplot--turn-off-context-sensitive-mode)))
 
 (eval-when-compile
   (defmacro gnuplot-foreach-buffer (&rest forms)
@@ -2187,7 +2187,9 @@ there."
 ;; Completions
 (defun gnuplot-completions ()
   (gnuplot-parse-at-point t)
-  gnuplot-completions)
+  (if (featurep 'xemacs)                ; Need an alist
+      (mapcar (lambda (s) (cons s nil)) gnuplot-completions)
+    gnuplot-completions))
 
 (defun gnuplot-context-completion-at-point ()
   "Return completions of keyword preceding point, using context."
@@ -2198,13 +2200,15 @@ there."
            (point)))
         (word nil)
         (completions (gnuplot-completions)))
-    (unless (= beg end)
-      (setq word (buffer-substring beg end)
-           completions (all-completions word completions)))
+    
+    (setq word (buffer-substring beg end)
+          completions (all-completions word completions))
 
     (if completions
        (list beg end completions)
-      (message "No gnuplot keywords complete '%s'" word)
+      (if (not (equal "" word))
+          (message "No gnuplot keywords complete '%s'" word)
+        (message "No completions at point"))
       nil)))
 
 ;; Eldoc help
diff --git a/gnuplot.el b/gnuplot.el
index 71f78c9..1b1c3fa 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -391,6 +391,11 @@ real work."
              '(gnuplot-comint-complete)))
         (comint-dynamic-complete))))
 
+;; Workaround for differing eval-after-load behavior
+(defun gnuplot--run-after-load (fun)
+  (if (featurep 'gnuplot)
+      (funcall fun)
+    (add-hook 'gnuplot-load-hook fun)))
 
 
 ;;;;
@@ -643,11 +648,13 @@ gnuplot-context if it is not being enabled."
   (if (featurep 'gnuplot-context)
       ;; Already loaded, OK to enable or disable
       (gnuplot-context-sensitive-mode (if value 1 0))
-    ;; Not loaded; load gnuplot-context only if enabling
+    ;; Not loaded; autoload gnuplot-context only if enabling
     (if value
-        (progn
-          (load "gnuplot-context")
-          (gnuplot-context-sensitive-mode 1))
+        ;; Prevent recursive (require 'gnuplot) loop when running
+        ;; interpreted
+        (gnuplot--run-after-load
+         #'(lambda ()
+             (gnuplot-context-sensitive-mode 1)))
       (setq gnuplot-context-sensitive-mode nil))))
 
 (defcustom gnuplot-context-sensitive-mode nil

Reply via email to