[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 40efb8e 067/184: Make loading of gnuplot work with
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 40efb8e 067/184: Make loading of gnuplot work with and without gnuplot-context. |
Date: |
Sun, 29 Aug 2021 11:03:17 -0400 (EDT) |
branch: elpa/gnuplot
commit 40efb8e8b757ab7907e1aec75769f59b2e6dd4bf
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Make loading of gnuplot work with and without gnuplot-context.
This is a bit tricky and there may well be a better solution. Here's
how it works:
- gnuplot-context.el is not loaded automatically by gnuplot.el
- function `gnuplot-context-sensitive-mode', the main on/off switch
for contextual parsing, is defined in `gnuplot-context.el' and
marked as autoloaded in `gnuplot.el'. This makes the menu item and
M-x gnuplot-context-sensitive-mode work, by loading the
gnuplot-context library as soon as it's needed
- defcustoms relating to context-sensitive mode are in gnuplot.el, so
that context mode can be discovered and enabled without an explicit
(require 'gnuplot-context). A special :set function for the
defcustom `gnuplot-context-sensitive-mode' loads gnuplot-context.el
only if enabling the mode. defcustom has a :require option which
seems like it would be made for this, but in fact it loads the
library independent of whether it's enabled or not, AFAICT.
---
gnuplot-context.el | 98 ++++++++++++++++++++++++------------------------------
gnuplot.el | 65 ++++++++++++++++++++++++++++++++++--
2 files changed, 105 insertions(+), 58 deletions(-)
diff --git a/gnuplot-context.el b/gnuplot-context.el
index 3ee35bd..b65c890 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -272,7 +272,7 @@ These have to be compiled from the Gnuplot source tree using
(setq gnuplot-eldoc-hash (make-hash-table))))
-;;;; Customization interface, etc.
+;;;; Interface to turning the mode on and off
(defun gnuplot-context-sensitive-mode (&optional enable)
"Turn gnuplot-mode context-sensitive completion and help on and off.
@@ -309,39 +309,57 @@ off. With no argument, toggle context-sensitive mode."
(interactive "P")
(setq gnuplot-context-sensitive-mode
(if (null enable) (not gnuplot-context-sensitive-mode)
- (> (prefix-numeric-value enable) 0)))
+ (> (prefix-numeric-value enable) 0)))
(if gnuplot-context-sensitive-mode
;; Turn on
(progn
(when (called-interactively-p 'any)
(message "Gnuplot context-sensitive help & completion enabled."))
- (ad-enable-advice 'gnuplot-completion-at-point
- 'around 'gnuplot-context)
- (ad-activate 'gnuplot-completion-at-point)
-
- (dolist (keymap (list gnuplot-mode-map gnuplot-comint-mode-map))
- (define-key keymap (kbd "C-c M-h") 'gnuplot-help-function)
- (define-key keymap (kbd "C-c C-/") 'gnuplot-help-function)
- (define-key keymap (kbd "C-c C-d") 'gnuplot-info-at-point))
- (define-key gnuplot-comint-mode-map (kbd "TAB")
'comint-dynamic-complete)
-
- (add-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
- (add-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc))
+ (eval-after-load 'gnuplot '(gnuplot--turn-on-context-sensitive-mode)))
;; Turn off
(when (called-interactively-p 'any)
(message "Gnuplot context-sensitive help & completion disabled."))
- (dolist (keymap (list gnuplot-mode-map gnuplot-comint-mode-map))
- (define-key keymap (kbd "C-c M-h") 'undefined)
- (define-key keymap (kbd "C-c C-/") 'undefined)
- (define-key keymap (kbd "C-c C-d") 'gnuplot-info-lookup-symbol))
- (ad-disable-advice 'gnuplot-completion-at-point
- 'around 'gnuplot-context)
- (ad-activate 'gnuplot-completion-at-point)
-
- (remove-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
- (remove-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc)
+ (eval-after-load 'gnuplot '(gnuplot--turn-off-context-sensitive-mode))))
+
+(eval-when-compile
+ (defmacro gnuplot-foreach-buffer (&rest forms)
+ (declare (indent 0))
+ `(dolist (buf (buffer-list))
+ (when (memq (buffer-local-value 'major-mode buf)
+ '(gnuplot-mode gnuplot-comint-mode))
+ (with-current-buffer buf
+ ,@forms)))))
+
+(defun gnuplot--turn-on-context-sensitive-mode ()
+ (ad-enable-advice 'gnuplot-completion-at-point
+ 'around 'gnuplot-context)
+ (ad-activate 'gnuplot-completion-at-point)
+
+ (dolist (keymap (list gnuplot-mode-map gnuplot-comint-mode-map))
+ (define-key keymap (kbd "C-c M-h") 'gnuplot-help-function)
+ (define-key keymap (kbd "C-c C-/") 'gnuplot-help-function)
+ (define-key keymap (kbd "C-c C-d") 'gnuplot-info-at-point))
+ (define-key gnuplot-comint-mode-map (kbd "TAB") 'comint-dynamic-complete)
+
+ (add-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
+ (add-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc)
+ (gnuplot-foreach-buffer (gnuplot-setup-eldoc)))
+
+(defun gnuplot--turn-off-context-sensitive-mode ()
+ (dolist (keymap (list gnuplot-mode-map gnuplot-comint-mode-map))
+ (define-key keymap (kbd "C-c M-h") 'undefined)
+ (define-key keymap (kbd "C-c C-/") 'undefined)
+ (define-key keymap (kbd "C-c C-d") 'gnuplot-info-lookup-symbol))
+ (ad-disable-advice 'gnuplot-completion-at-point
+ 'around 'gnuplot-context)
+ (ad-activate 'gnuplot-completion-at-point)
+
+ (remove-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
+ (remove-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc)
+ (gnuplot-foreach-buffer
+ (setq eldoc-documentation-function nil)
(eldoc-mode 0)))
;; Has to be defined here. Grumble.
@@ -350,36 +368,6 @@ off. With no argument, toggle context-sensitive mode."
;; context-sensitivity on and off
(setq ad-return-value (gnuplot-context-completion-at-point)))
-(defcustom gnuplot-context-sensitive-mode nil
- "Whether context-sensitive completion and help for gnuplot are enabled.
-
-With context-sensitive mode on, gnuplot-mode's tab completion and
-info file lookup try to parse the current command line to find
-the most useful completions or info pages.
-
-Don't set this variable from Lisp code; instead, use Customize or
-call the `gnuplot-context-sensitive-mode' function, which behaves
-like a minor mode."
- :group 'gnuplot
- :type 'boolean
- :set 'custom-set-minor-mode
- :link '(emacs-commentary-link "gnuplot-context"))
-
-(defcustom gnuplot-eldoc-mode nil
- "Whether to enable ElDoc mode by default in Gnuplot buffers.
-ElDoc support requires `gnuplot-context-sensitive-mode' to be
-on."
- :group 'gnuplot
- :type 'boolean)
-
-(defcustom gnuplot-tab-completion nil
- "Whether the TAB key should perform completion in gnuplot-mode buffers.
-
-Setting this to `t' sets the `tab-always-indent' variable to the
-symbol `complete' in gnuplot-mode buffers."
- :group 'gnuplot
- :type 'boolean)
-
(defun gnuplot-setup-eldoc ()
(set (make-local-variable 'eldoc-documentation-function)
'gnuplot-eldoc-function)
@@ -2322,4 +2310,4 @@ command."
;;; All done!
(provide 'gnuplot-context)
-;;; gnuplot-context.el ends here
\ No newline at end of file
+;;; gnuplot-context.el ends here
diff --git a/gnuplot.el b/gnuplot.el
index fa75143..0f8e404 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -5,8 +5,8 @@
;; Author: Bruce Ravel <bruceravel1@gmail.com> and Phil Type
;; Maintainer: Bruce Ravel <bruceravel1@gmail.com>
;; Created: June 28 1998
-;; Updated: April 20 2012
-;; Version: 0.6.1
+;; Updated: October 05 2012
+;; Version: 0.7
;; Keywords: gnuplot, plotting
;; This file is not part of GNU Emacs.
@@ -96,6 +96,15 @@
;; Defines the GUI interface for setting setting arguments to
;; gnuplot options. This uses the widget package extensively.
;;
+;; gnuplot-context.el (written by Jonathan, j.j.oddie@gmail.com)
+;; Provides context-sensitive completion, help lookup and eldoc
+;; strings for gnuplot buffers. This is somewhat experimental, which
+;; is why it is a separate library for now. It should be
+;; byte-compiled before using. Run `gnuplot-context-sensitive-mode'
+;; (which autoloads the file) to try it out, and see the commentary
+;; of gnuplot-context.el for more.
+;;
+
;; ---------------------------------------------------------------------
;;
;; This mode was inspired by the original gnu-plot-mode by Gershon
@@ -283,6 +292,9 @@
;; 0.6.0 Dec 13 2002 <BR> Changed numbering scheme to accommodate
;; gnuplot packaging requirements
;; 0.6.1 Sep 13 2011 <BR> Moved to github, updated contact info
+;; 0.7 Oct 20 2012 <jjo> Contextual completion & help, inline plots,
+;; some other stuff
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Acknowledgements:
;; David Batty <DB> (numerous corrections)
@@ -303,6 +315,8 @@
;; Michael M. Tung <MT> (prompted me to add pm3d support)
;; Holger Wenzel <HW> (suggested using `gnuplot-keywords-when')
;; Wolfgang Zocher <WZ> (pointed out problem with gnuplot-mode + speedbar)
+;; Jon Oddie <jjo> (indentation, inline images, context mode)
+;;
;; and especially to Lars Hecking <LH> for including gnuplot-mode
;; with the gnuplot 3.7-beta distribution and for providing me with
;; installation materials
@@ -357,7 +371,7 @@
(defconst gnuplot-maintainer-email "ravel@phys.washington.edu")
(defconst gnuplot-maintainer-url
"http://github.com/bruceravel/gnuplot-mode/")
-(defconst gnuplot-version "0.6.1")
+(defconst gnuplot-version "0.7")
(defgroup gnuplot nil
"Gnuplot-mode for Emacs."
@@ -591,6 +605,51 @@ you're not using that musty old thing, are you..."
'(radio (const :tag "Parse info file when gnuplot-mode starts"
immediately)
(const :tag "Parse info file the first time it is needed" deferred)))
+(defun gnuplot-set-context-mode (variable value)
+ "Turn context-sensitive mode on or off through Customize.
+
+Unlike the built-in custom-set-minor-mode, this avoids loading
+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
+ (if value
+ (progn
+ (load "gnuplot-context")
+ (gnuplot-context-sensitive-mode 1))
+ (setq gnuplot-context-sensitive-mode nil))))
+
+(defcustom gnuplot-context-sensitive-mode nil
+ "Non-nil if contextual completion and help for gnuplot are enabled.
+
+With context-sensitive mode on, gnuplot-mode's tab completion and
+info file lookup try to parse the current command line to find
+the most useful completions or info pages.
+
+Don't set this variable from Lisp code; instead, use Customize or
+call the `gnuplot-context-sensitive-mode' function, which behaves
+like a minor mode."
+ :group 'gnuplot
+ :type 'boolean
+ :set 'gnuplot-set-context-mode
+ :link '(emacs-commentary-link "gnuplot-context"))
+
+(defcustom gnuplot-eldoc-mode nil
+ "Non-nil if ElDoc mode should be enabled by default in Gnuplot buffers.
+ElDoc support requires `gnuplot-context-sensitive-mode' to be
+on."
+ :group 'gnuplot
+ :type 'boolean)
+
+(defcustom gnuplot-tab-completion nil
+ "Non-nil if TAB should perform completion in gnuplot-mode buffers.
+
+Setting this to `t' sets the `tab-always-indent' variable to the
+symbol `complete' in gnuplot-mode buffers."
+ :group 'gnuplot
+ :type 'boolean)
+
(defgroup gnuplot-faces nil
"Text faces used by gnuplot-mode."
:prefix "gnuplot-"
- [nongnu] elpa/gnuplot aba40f1 034/184: Document the change to `gnuplot-make-regexp', (continued)
- [nongnu] elpa/gnuplot aba40f1 034/184: Document the change to `gnuplot-make-regexp', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 72ccda3 017/184: Improved syntax parsing and highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2387f12 016/184: Restored some XEmacs compatibility that I broke., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot df865fc 013/184: Slight change to font-lock regexps, and use buffer-local variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0faec4f 022/184: Check that gnuplot-process is not nil in gnuplot-close-down, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 57fd4a2 036/184: Attempt to fix issue #9, void-function gnuplot-start-comint-function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ca241a7 035/184: Merge remote-tracking branch 'origin/devel' into devel, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7f29578 023/184: Minor improvements to movement-by-command functions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 8d367f5 028/184: Better assignment-matching regexp (?), ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 049f953 044/184: Use absolute locations in all jump/call/choice/commit instructions., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 40efb8e 067/184: Make loading of gnuplot work with and without gnuplot-context.,
ELPA Syncer <=
- [nongnu] elpa/gnuplot 0d2079a 056/184: Fixed a regression in 7cb3975 relating to scanning stack at end-of-command, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2bf9779 063/184: Remove macro hacks for ancient Emacs versions, as per issue #12, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot cf513f9 049/184: Added (require 'eldoc) to gnuplot-context.el. Improved documentation., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a7cfd1d 055/184: Abbreviate "print" command, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ae5e628 074/184: Make context completion work on xemacs (21.4), ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6e0ed5f 050/184: Added x2label, y2label to grammar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 89e5445 053/184: Add customization options to turn context completion on and off., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ffe6c66 059/184: First shot at implementing inline plot images in process buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 5030976 051/184: Alter header to conform to package.el specifications, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e02534c 066/184: Add menu items for context-sensitive and inline-image modes, ELPA Syncer, 2021/08/29