[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 0ff395e 071/184: Compatibility hacks for pre-23 em
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 0ff395e 071/184: Compatibility hacks for pre-23 emacs versions |
Date: |
Sun, 29 Aug 2021 11:03:17 -0400 (EDT) |
branch: elpa/gnuplot
commit 0ff395e2d3c8ab1e1f87f98ed867b827431e83bb
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Compatibility hacks for pre-23 emacs versions
---
gnuplot-context.el | 33 ++++++++++++++++++------
gnuplot.el | 73 +++++++++++++++++++++++++++++++++++-------------------
2 files changed, 74 insertions(+), 32 deletions(-)
diff --git a/gnuplot-context.el b/gnuplot-context.el
index b65c890..6354e33 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -251,10 +251,12 @@
;;
;;
-(eval-when-compile (require 'cl))
+(eval-when-compile
+ (require 'cl)
+ (require 'advice)
-;; Prevent compiler warnings about undefined functions
-(eval-when-compile (require 'gnuplot))
+ ;; Prevent compiler warnings about undefined functions
+ (require 'gnuplot))
;; We need ElDoc support
(require 'eldoc)
@@ -272,8 +274,23 @@ These have to be compiled from the Gnuplot source tree
using
(setq gnuplot-eldoc-hash (make-hash-table))))
+;;;; 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)))
+
+ (when (not (fboundp 'info-other-window))
+ (defmacro info-other-window (&rest args)
+ `(info ,@args))))
+
+
;;;; Interface to turning the mode on and off
-(defun gnuplot-context-sensitive-mode (&optional enable)
+(defun gnuplot-context-sensitive-mode (&optional enable called-interactively-p)
"Turn gnuplot-mode context-sensitive completion and help on and off.
When context-sensitive mode is enabled, gnuplot-mode tries to
@@ -306,7 +323,9 @@ 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 "P")
+ (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)))
@@ -314,12 +333,12 @@ off. With no argument, toggle context-sensitive mode."
(if gnuplot-context-sensitive-mode
;; Turn on
(progn
- (when (called-interactively-p 'any)
+ (when called-interactively-p
(message "Gnuplot context-sensitive help & completion enabled."))
(eval-after-load 'gnuplot '(gnuplot--turn-on-context-sensitive-mode)))
;; Turn off
- (when (called-interactively-p 'any)
+ (when called-interactively-p
(message "Gnuplot context-sensitive help & completion disabled."))
(eval-after-load 'gnuplot '(gnuplot--turn-off-context-sensitive-mode))))
diff --git a/gnuplot.el b/gnuplot.el
index 2906fef..a06b9f9 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -363,6 +363,37 @@
(require 'info-look)
(error nil)))
+;; Misc. compatibility hacks
+(if (featurep 'xemacs)
+ ;; XEmacs
+ (progn
+ (defun gnuplot-set-minor-mode (variable value)
+ ":set function for minor mode variables."
+ (funcall variable (if value 1 0)))
+
+ ;; Inline image mode only works on GNU Emacs for now. Sorry.
+ (defun gnuplot-display-images-p () nil))
+
+ ;; GNU Emacs
+ (defalias 'gnuplot-set-minor-mode 'custom-set-minor-mode)
+ (defalias 'gnuplot-display-images-p 'display-images-p))
+
+;; Hack for Emacs < 22
+(if (not (fboundp 'completion-at-point))
+ (defun gnuplot-xemacs-completion-at-point ()
+ "Perform completion on keyword preceding point.
+
+This binds `comint-dynamic-complete-functions' to
+`gnuplot-comint-complete' and uses `comint-dynamic-complete' to do the
+real work."
+ (interactive)
+ (let ((comint-dynamic-complete-functions
+ '(gnuplot-comint-complete)))
+ (comint-dynamic-complete))))
+
+
+
+;;;;
(defconst gnuplot-xemacs-p (string-match "XEmacs" (emacs-version)))
(defconst gnuplot-ntemacs-p (string-match "msvc" (emacs-version)))
(defvar gnuplot-three-eight-p "")
@@ -408,6 +439,7 @@ region, a buffer, or a file."
:group 'gnuplot-hooks
:type 'hook)
+
(defcustom gnuplot-info-hook nil
"*Hook run before setting up the info-look interface.
This hook is necessary to handle inconsistencies in versions of and
@@ -694,9 +726,9 @@ symbol `complete' in gnuplot-mode buffers."
(define-key gnuplot-mode-map "\C-c\M-i" 'gnuplot-inline-image-mode)
(let ((completion-function
- (if (featurep 'xemacs)
- 'gnuplot-xemacs-completion-at-point
- 'completion-at-point)))
+ (if (fboundp 'completion-at-point)
+ 'completion-at-point
+ 'gnuplot-xemacs-completion-at-point)))
(define-key gnuplot-mode-map "\M-\r" completion-function)
(define-key gnuplot-mode-map "\M-\t" completion-function))
@@ -721,14 +753,14 @@ symbol `complete' in gnuplot-mode buffers."
["Send file to gnuplot" gnuplot-send-file-to-gnuplot t]
"---"
["Inline plot display" gnuplot-inline-image-mode
- :enable (display-images-p)
+ :active (gnuplot-display-images-p)
:style toggle
:selected gnuplot-inline-image-mode]
["Contextual completion and help" gnuplot-context-sensitive-mode
:style toggle
:selected (gnuplot-context-mode-p)]
["Echo area help (eldoc-mode)" eldoc-mode
- :enable (gnuplot-context-mode-p)
+ :active (gnuplot-context-mode-p)
:style toggle
:selected eldoc-mode]
"---"
@@ -2154,14 +2186,14 @@ buffer."
(buffer-live-p gnuplot-comint-recent-buffer)]
"---"
["Inline plot display" gnuplot-inline-image-mode
- :enable (display-images-p)
+ :active (gnuplot-display-images-p)
:style toggle
:selected gnuplot-inline-image-mode]
["Contextual completion and help" gnuplot-context-sensitive-mode
:style toggle
:selected (gnuplot-context-mode-p)]
["Echo area help (eldoc-mode)" eldoc-mode
- :enable (gnuplot-context-mode-p)
+ :active (gnuplot-context-mode-p)
:style toggle
:selected eldoc-mode]
"---"
@@ -2335,7 +2367,7 @@ gnuplot process buffer will be displayed in a window."
;;; --- Support for displaying plot images inline in process buffer,
;;; using `set terminal png' <JJO>
-(defun gnuplot-inline-image-mode (&optional enable)
+(defun gnuplot-inline-image-mode (&optional enable called-interactively-p)
"Turn inline display of Gnuplot output in the comint buffer on or off.
This works by having Gnuplot save its output to temporary .png
@@ -2347,19 +2379,21 @@ Works like a minor mode: with argument, turn inline
image display
on if ENABLE is positive, otherwise turn it off and restores the
previous Gnuplot terminal setting. With no argument, toggle
inline image display."
- (interactive "P")
+ (interactive (list (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg))
+ t))
(setq gnuplot-inline-image-mode
(if (null enable) (not gnuplot-inline-image-mode)
(> (prefix-numeric-value enable) 0)))
(let (message)
(if gnuplot-inline-image-mode
- (if (display-images-p)
+ (if (gnuplot-display-images-p)
(setq message "Plot output will be displayed in gnuplot buffer.")
(setq gnuplot-inline-image-mode nil
message "Displaying images is not supported."))
(setq message "Plot output will be displayed on external terminal."))
- (when (called-interactively-p 'any) (message message)))
+ (when called-interactively-p (message message)))
(when (and gnuplot-buffer (buffer-name gnuplot-buffer))
(with-current-buffer gnuplot-buffer
@@ -2373,6 +2407,8 @@ inline image display."
(remove-hook 'comint-output-filter-functions
'gnuplot-insert-inline-image-output t)))))
+;; Has to be defined below the function, due to how
+;; custom-set-minor-mode works. Or is there a better way??
(defcustom gnuplot-inline-image-mode nil
"Whether to enable inline display of Gnuplot output in the process buffer.
Don't set this variable directly from Lisp code; instead, use
@@ -2380,7 +2416,7 @@ Customize or call the `gnuplot-inline-image-mode'
function, which
behaves like a minor-mode function."
:group 'gnuplot
:type 'boolean
- :set 'custom-set-minor-mode)
+ :set 'gnuplot-set-minor-mode)
(defvar gnuplot-inline-image-filename nil
"Name of the current Gnuplot PNG output file.")
@@ -2761,19 +2797,6 @@ Return a list of keywords."
(delete "nil" store)
store ))
-(defun gnuplot-xemacs-completion-at-point ()
- "Perform completion on keyword preceding point.
-
-This binds `comint-dynamic-complete-functions' to
-`gnuplot-comint-complete' and uses `comint-dynamic-complete' to do the
-real work."
- ;; This actually would work in GNU Emacs too, but that seems a bit
- ;; hackish when completion-at-point exists
- (interactive)
- (let ((comint-dynamic-complete-functions
- '(gnuplot-comint-complete)))
- (comint-dynamic-complete)))
-
(defun gnuplot-completion-at-point ()
"Return completions of keyword preceding point.
- [nongnu] elpa/gnuplot 2bf9779 063/184: Remove macro hacks for ancient Emacs versions, as per issue #12, (continued)
- [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
- [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 <=
- [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
- [nongnu] elpa/gnuplot c520e94 075/184: Remove a redundant check for gnuplot-keywords-pending, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6792a81 083/184: Simple indentation fix for new block-structured do and if, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7e33d0d 087/184: three fixes: indentation, require cl macros, fix defc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 9dd0e15 096/184: Avoid having text syntax-property changes mark buffer as modified, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c52bb6c 089/184: grammar fixes for new-style if statement and blocks, ELPA Syncer, 2021/08/29