Skip to content

Commit

Permalink
Make context completion work on xemacs (21.4)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
joddie committed Oct 11, 2012
1 parent af7e8de commit ae5e628
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
18 changes: 11 additions & 7 deletions gnuplot-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions gnuplot.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))


;;;;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ae5e628

Please sign in to comment.