[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot d0828c0 126/184: Make gnuplot-context-sensitive-mo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot d0828c0 126/184: Make gnuplot-context-sensitive-mode a normal minor mode |
Date: |
Sun, 29 Aug 2021 11:03:29 -0400 (EDT) |
branch: elpa/gnuplot
commit d0828c027e4c0ddb5a311b639b7f6cade333d12c
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Make gnuplot-context-sensitive-mode a normal minor mode
---
gnuplot-context.el | 137 +++++++++++++++++++----------------------------------
1 file changed, 48 insertions(+), 89 deletions(-)
diff --git a/gnuplot-context.el b/gnuplot-context.el
index 5b60096..4ba8c10 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -262,21 +262,16 @@
These have to be compiled from the Gnuplot source tree using
`doc2texi.el'.")
-
-;;;; Compatibility for Emacs version < 23
+;; Compatibility for Emacs version < 23
(eval-when-compile
(when (not (fboundp 'string-match-p))
(defmacro string-match-p (&rest args)
- `(save-match-data (string-match ,@args))))
-
- (when (not (fboundp 'buffer-local-value))
- (defmacro buffer-local-value (variable buffer)
- `(with-current-buffer ,buffer ,variable))))
+ `(save-match-data (string-match ,@args)))))
-;;;; Interface to turning the mode on and off
-(defun gnuplot-context-sensitive-mode (&optional enable called-interactively-p)
- "Turn gnuplot-mode context-sensitive completion and help on and off.
+;;;; Minor mode
+(define-minor-mode gnuplot-context-sensitive-mode
+ "Use context-sensitive completion and help in gnuplot-mode.
When context-sensitive mode is enabled, gnuplot-mode tries to
provide more useful completions and help suggestions for built-in
@@ -296,96 +291,60 @@ buffers.
Gnuplot info node for the construction at point, prompting for a
node name if nothing is found.
-In addition, \\[gnuplot-help-function] will pop up a brief
-summary of the syntax at point in the minibuffer. To have one-line
-syntax summaries appear in the echo area as you type, toggle
+\\[gnuplot-help-function] will pop up a brief summary of the
+syntax at point in the minibuffer. To have one-line syntax
+summaries appear in the echo area as you type, toggle
`eldoc-mode' or customize `gnuplot-eldoc-mode'.
Note: help strings for eldoc-mode and \\[gnuplot-help-function]
need to be provided in an Emacs-readable form by the Gnuplot
-distribution. See gnuplot-context.el for details.
-
-Works like a minor mode: with a prefix argument, turn
-context-sensitive mode on if positive, otherwise turn it
-off. With no argument, toggle context-sensitive mode."
- (interactive (list (if current-prefix-arg
- (prefix-numeric-value current-prefix-arg))
- t))
- (setq gnuplot-context-sensitive-mode
- (if (null enable) (not gnuplot-context-sensitive-mode)
- (> (prefix-numeric-value enable) 0)))
-
+distribution. See gnuplot-context.el for details."
+ :keymap
+ `((,(kbd "C-c C-/") . gnuplot-help-function)
+ (,(kbd "C-c C-d") . gnuplot-info-at-point))
+ (unless (derived-mode-p 'gnuplot-mode 'gnuplot-comint-mode)
+ (message "Gnuplot context-sensitive mode works only in Gnuplot-mode
buffers")
+ (setq gnuplot-context-sensitive-mode nil))
(if gnuplot-context-sensitive-mode
;; Turn on
(progn
+ (setq gnuplot-completion-at-point-function
#'gnuplot-context-completion-at-point)
+ (define-key gnuplot-comint-mode-map (kbd "TAB")
'comint-dynamic-complete)
+
+ ;; Setup Eldoc
+ (set (make-local-variable 'eldoc-documentation-function)
+ 'gnuplot-eldoc-function)
+ (eldoc-add-command 'completion-at-point) ; Check for eldoc after
completion
+ (when (fboundp 'comint-dynamic-complete)
+ (eldoc-add-command 'comint-dynamic-complete))
+
+ ;; Try to load Eldoc strings
+ (when gnuplot-eldoc-mode
+ (unless gnuplot-eldoc-hash
+ (condition-case nil
+ (load-library "gnuplot-eldoc")
+ (error
+ (message "gnuplot-eldoc.el not found. Install it from the
Gnuplot distribution.")
+ (setq gnuplot-eldoc-hash nil
+ gnuplot-eldoc-mode nil))))
+
+ (if gnuplot-eldoc-hash
+ (eldoc-mode 1)
+ (eldoc-mode 0)))
+
+ ;; Set up tab-to-complete
+ (when gnuplot-tab-completion
+ (set (make-local-variable 'tab-always-indent) 'complete))
+
(when called-interactively-p
- (message "Gnuplot context-sensitive help & completion enabled."))
- (gnuplot--run-after-load 'gnuplot--turn-on-context-sensitive-mode))
+ (message "Gnuplot context-sensitive help & completion enabled.")))
;; Turn off
- (when called-interactively-p
- (message "Gnuplot context-sensitive help & completion disabled."))
- (gnuplot--run-after-load '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 ()
- (setq gnuplot-completion-at-point-function
#'gnuplot-context-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))
- (setq gnuplot-completion-at-point-function
#'gnuplot-completion-at-point-info-look)
-
- (remove-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
- (remove-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc)
- (gnuplot-foreach-buffer
+ (setq gnuplot-completion-at-point-function
#'gnuplot-completion-at-point-info-look)
(setq eldoc-documentation-function nil)
- (eldoc-mode 0)))
-
-(defun gnuplot-setup-eldoc ()
- (set (make-local-variable 'eldoc-documentation-function)
- 'gnuplot-eldoc-function)
-
- ;; Check for ElDoc after doing completion
- (eldoc-add-command 'completion-at-point)
- (eldoc-add-command 'comint-dynamic-complete)
-
- (when gnuplot-eldoc-mode
- (unless gnuplot-eldoc-hash
- (condition-case nil
- (load-library "gnuplot-eldoc")
- (error
- (message "gnuplot-eldoc.el not found. Install it from the Gnuplot
distribution.")
- (setq gnuplot-eldoc-hash nil
- gnuplot-eldoc-mode nil))))
-
- (if gnuplot-eldoc-hash
- (eldoc-mode 1)
- (eldoc-mode 0)))
-
- (when gnuplot-tab-completion
- (set (make-local-variable 'tab-always-indent) 'complete)))
-
+ (eldoc-mode 0)
+ (when called-interactively-p
+ (message "Gnuplot context-sensitive help & completion disabled."))))
;;;; The tokenizer.
- [nongnu] elpa/gnuplot f5c4437 100/184: Reduce autotools dependency to version 2.61, (continued)
- [nongnu] elpa/gnuplot f5c4437 100/184: Reduce autotools dependency to version 2.61, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e1ee092 097/184: Merge branch 'devel' containing 0.7 release candidate., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d9ed05b 105/184: remove broken link from readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot aefd4f6 106/184: Cleanup version numbers and copyright dates, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4858b0d 110/184: Set syntax table in comint buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c2aedf8 111/184: Add ERT tests to check comment and string syntax., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 5efb8a9 112/184: Add Makefile targets to run all tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ed930f3 116/184: Fix compile errors when testing from command line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2f36b36 118/184: Update Makefile.in, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a50ac2b 119/184: Add autoloaded `run-gnuplot` command, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d0828c0 126/184: Make gnuplot-context-sensitive-mode a normal minor mode,
ELPA Syncer <=
- [nongnu] elpa/gnuplot 71e3174 129/184: Remove un-needed run-after-load hackery, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d899379 123/184: Clarify comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 536f2c3 122/184: Put alias for missing syntax-ppss with the other workarounds, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot b6eea0b 133/184: Add :set function for customizing context-sensitive mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c4d464a 125/184: Use `gnuplot-completion-at-point-function' instead of advice hackery, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot da11bfa 128/184: New customize option `gnuplot-use-context-sensitive-completion', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f274ad7 138/184: Recommend to use GitHub bug tracker instead of E-mail, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 54fd3eb 141/184: do toolbar-make-button-list after check the function exists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 14584a0 143/184: clean Elisp format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a080f79 149/184: Merge pull request #45 from conao3/fix-trivial, ELPA Syncer, 2021/08/29