[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 89e5445 053/184: Add customization options to turn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 89e5445 053/184: Add customization options to turn context completion on and off. |
Date: |
Sun, 29 Aug 2021 11:03:14 -0400 (EDT) |
branch: elpa/gnuplot
commit 89e54456d8a7702c003af19744c86db78fb33d1a
Author: Jonathan Oddie <j.j.oddie@gmail.com>
Commit: Jonathan Oddie <j.j.oddie@gmail.com>
Add customization options to turn context completion on and off.
This involves defining `gnuplot-context-sensitive-mode' variable &
function (like a minor mode), and using advice on
`gnuplot-completion-at-point' instead of redefining it. Slightly ugly,
but should be more modular as loading gnuplot-context by itself won't
change anything.
Also added customization options for turning eldoc and smart tab
completion on by default in gnuplot buffers.
---
gnuplot-context.el | 123 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 100 insertions(+), 23 deletions(-)
diff --git a/gnuplot-context.el b/gnuplot-context.el
index a6f98b7..9bf5f95 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -1,11 +1,11 @@
-;;;; gnuplot-context.el -- context-sensitive help and completion for gnuplot
+;;; gnuplot-context.el -- context-sensitive help and completion for gnuplot
;; Copyright (C) 2012 Jonathan Oddie <j.j.oddie@gmail.com>
;; Author: Jonathan Oddie <j.j.oddie@gmail.com>
;; Maintainer: Jonathan Oddie <j.j.oddie@gmail.com>
;; Created: Wednesday, 08 February 2012
-;; Updated: Sunday, 08 April 2012
+;; Updated: Friday, 20 April 2012
;; Version: 0.6.1
;; Keywords: gnuplot, plotting
@@ -32,7 +32,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; send bug reports to the author (j.j.oddie@gmail.com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;;; Commentary:
+
;;
;; This file enhances gnuplot-mode by providing context-sensitive
;; completion, ElDoc support, and info page lookup for gnuplot script
@@ -270,6 +272,99 @@ These have to be compiled from the Gnuplot source tree
using
(setq gnuplot-eldoc-hash (make-hash-table))))
+;;;; Customization interface, etc.
+(defun gnuplot-context-sensitive-mode (&optional enable)
+ "Turn gnuplot-mode context-sensitive completion and help on and off.
+Works like a minor mode: with argument, turn context-sensitive
+mode on if ENABLE is positive, otherwise turn it 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)))
+
+ (if gnuplot-context-sensitive-mode
+ (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))
+
+ ;; 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)))
+
+;; Has to be defined here. Grumble.
+(defadvice gnuplot-completion-at-point (around gnuplot-context disable)
+ ;; This around-advice gets activated/deactivated when turning
+ ;; 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)
+
+ ;; Check for ElDoc after doing completion
+ (eldoc-add-command 'completion-at-point)
+ (eldoc-add-command 'comint-dynamic-complete)
+
+ (when gnuplot-eldoc-mode
+ (eldoc-mode))
+ (when gnuplot-tab-completion
+ (set (make-local-variable 'tab-always-indent) 'complete)))
+
+
+
;;;; The tokenizer.
(defstruct gnuplot-token
@@ -2054,8 +2149,8 @@ there."
(gnuplot-parse-at-point t)
gnuplot-completions)
-(defun gnuplot-completion-at-point ()
- "Return completions of keyword preceding point."
+(defun gnuplot-context-completion-at-point ()
+ "Return completions of keyword preceding point, using context."
(let* ((end (point))
(beg
(save-excursion
@@ -2087,21 +2182,6 @@ there."
(cadr (gethash gnuplot-info-at-point gnuplot-eldoc-hash))))
(if eldoc (message eldoc)))))
-(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))
-
-(define-key gnuplot-mode-map (kbd "C-c M-h") 'gnuplot-help-function)
-(define-key gnuplot-mode-map (kbd "C-c C-/") 'gnuplot-help-function)
-(define-key gnuplot-comint-mode-map (kbd "C-c M-h") 'gnuplot-help-function)
-(define-key gnuplot-comint-mode-map (kbd "C-c C-/") 'gnuplot-help-function)
-
-(add-hook 'gnuplot-mode-hook 'gnuplot-setup-eldoc)
-(add-hook 'gnuplot-comint-mode-hook 'gnuplot-setup-eldoc)
-
;; Info lookup
(defun gnuplot-info-at-point (&optional query)
"Open the relevant gnuplot info page for the construction at point."
@@ -2120,9 +2200,6 @@ there."
(gnuplot-parse-at-point nil)
gnuplot-info-at-point)
-(define-key gnuplot-mode-map (kbd "C-c C-d") 'gnuplot-info-at-point)
-(define-key gnuplot-comint-mode-map (kbd "C-c C-d") 'gnuplot-info-at-point)
-(define-key gnuplot-comint-mode-map (kbd "TAB") 'comint-dynamic-complete)
@@ -2209,7 +2286,7 @@ command."
-;;;; All done!
+;;; All done!
(provide 'gnuplot-context)
;;; gnuplot-context.el ends here
\ No newline at end of file
- [nongnu] elpa/gnuplot 7f29578 023/184: Minor improvements to movement-by-command functions, (continued)
- [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, 2021/08/29
- [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 <=
- [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
- [nongnu] elpa/gnuplot a70749e 054/184: Fix "replot" command in grammar., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0ff395e 071/184: Compatibility hacks for pre-23 emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c3e13f0 076/184: change version number to 0.7beta to avoid any confusion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 319a176 072/184: clean up tests a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e9447f0 048/184: More consistent keys between gnuplot.el and gnuplot-context.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ea83e14 081/184: cleanup parsing tests some more, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot b618811 069/184: Silence some compiler warnings about obsolete font-lock faces, ELPA Syncer, 2021/08/29