[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 70dd22e 060/184: Keyboard shortcut and menu item f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 70dd22e 060/184: Keyboard shortcut and menu item for toggling inline mode. |
Date: |
Sun, 29 Aug 2021 11:03:15 -0400 (EDT) |
branch: elpa/gnuplot
commit 70dd22e42fd0808d92dbd9b80b836b9abe3093eb
Author: Jonathan Oddie <j.j.oddie@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Keyboard shortcut and menu item for toggling inline mode.
Some reorganization & docstrings.
---
gnuplot.el | 106 +++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 64 insertions(+), 42 deletions(-)
diff --git a/gnuplot.el b/gnuplot.el
index 071edd3..9d053be 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -659,6 +659,7 @@ you're not using that musty old thing, are you..."
(define-key gnuplot-mode-map "\C-c\C-z" 'gnuplot-customize)
(define-key gnuplot-mode-map "\C-i" 'indent-for-tab-command)
(define-key gnuplot-mode-map "\C-m" 'newline-and-indent)
+ (define-key gnuplot-mode-map "\C-c\M-i" 'gnuplot-inline-image-mode)
(let ((completion-function
(if (featurep 'xemacs)
@@ -699,6 +700,8 @@ you're not using that musty old thing, are you..."
(fboundp 'gnuplot-gui-set-options-and-insert)]
["Swap plot/splot/fit lists in GUI" gnuplot-gui-swap-simple-complete
(fboundp 'gnuplot-gui-swap-simple-complete)]
+ ["Toggle inline plot display" gnuplot-inline-image-mode
+ (display-images-p)]
"---"
["Customize gnuplot" gnuplot-customize t]
["Submit bug report" gnuplot-bug-report t]
@@ -2088,6 +2091,7 @@ buffer."
(define-key gnuplot-comint-mode-map "\C-c\C-u" 'gnuplot-bug-report)
(define-key gnuplot-comint-mode-map "\C-c\C-z" 'gnuplot-customize)
(define-key gnuplot-comint-mode-map "\C-c\C-e" 'gnuplot-pop-to-recent-buffer)
+(define-key gnuplot-comint-mode-map "\C-c\M-i" 'gnuplot-inline-image-mode)
;; Menu for gnuplot-comint-mode
(defvar gnuplot-comint-mode-menu nil
@@ -2106,6 +2110,8 @@ buffer."
(or gnuplot-keywords gnuplot-keywords-pending)]
["Switch to recent gnuplot script buffer"
gnuplot-pop-to-recent-buffer
(buffer-live-p gnuplot-comint-recent-buffer)]
+ ["Toggle inline plot display"
gnuplot-inline-image-mode
+ (display-images-p)]
"---"
["Customize gnuplot" gnuplot-customize t]
["Submit bug report" gnuplot-bug-report t]
@@ -2255,58 +2261,48 @@ gnuplot process buffer will be displayed in a window."
(switch-to-buffer gnuplot-buffer))))
-;;; --- inline image stuff <JJO>
-(defvar gnuplot-inline-image-filename nil)
+;;; --- Support for displaying plot images inline in process buffer,
+;;; using `set terminal png' <JJO>
-(defvar gnuplot-inline-image-mode 0)
+(defvar gnuplot-inline-image-filename nil
+ "Name of the current Gnuplot PNG output file.")
-(defvar gnuplot-inline-image-timestamp nil)
+(defvar gnuplot-inline-image-mode 0
+ "Whether inline Gnuplot image display is enabled: 1 for on, 0 for off.")
(defun gnuplot-inline-image-mode (&optional enable)
+ "Turn inline display of Gnuplot output in the comint buffer on or off.
+With ENABLE 0, turns inline image display off and restores the
+previous Gnuplot terminal setting. With ENABLE 1, turns inline
+image display on. With no argument, toggles inline image
+display."
(interactive)
- (setq enable (or enable
- (if (zerop gnuplot-inline-image-mode) 1 0)))
-
- (gnuplot-make-gnuplot-buffer)
- (with-current-buffer gnuplot-buffer
- (if (zerop enable)
- (progn
- (comint-send-string gnuplot-process "set terminal pop\n")
- (setq gnuplot-inline-image-mode 0)
- (remove-hook 'comint-output-filter-functions
- 'gnuplot-insert-inline-image-output t)
- (message "Plot output will be displayed on external terminal."))
- (comint-send-string gnuplot-process "set terminal png\n")
- (gnuplot-inline-image-set-output)
- (add-hook 'comint-output-filter-functions
- 'gnuplot-insert-inline-image-output nil t)
- (setq gnuplot-inline-image-mode 1)
- (message "Plot output will be displayed in gnuplot buffer."))))
+ (if (not (display-images-p))
+ (message "Displaying images is not supported.")
+ (setq enable (or enable
+ (if (zerop gnuplot-inline-image-mode) 1 0)))
+
+ (gnuplot-make-gnuplot-buffer)
+ (with-current-buffer gnuplot-buffer
+ (if (zerop enable)
+ (progn
+ (comint-send-string gnuplot-process "set terminal pop\n")
+ (setq gnuplot-inline-image-mode 0)
+ (remove-hook 'comint-output-filter-functions
+ 'gnuplot-insert-inline-image-output t)
+ (message "Plot output will be displayed on external terminal."))
+ (comint-send-string gnuplot-process "set terminal png\n")
+ (gnuplot-inline-image-set-output)
+ (add-hook 'comint-output-filter-functions
+ 'gnuplot-insert-inline-image-output nil t)
+ (setq gnuplot-inline-image-mode 1)
+ (message "Plot output will be displayed in gnuplot buffer.")))))
(defun gnuplot-inline-image-set-output ()
+ "Set GNUPLOT's output file to `gnuplot-inline-image-filename'."
(let ((tmp (make-temp-file "gnuplot")))
(setq gnuplot-inline-image-filename tmp)
(gnuplot-send-hiding-output (format "set output '%s'\n" tmp))))
-
-(defvar gnuplot-hidden-output-buffer " *gnuplot output*")
-
-(defun gnuplot-discard-output (string)
- (with-current-buffer
- (get-buffer-create gnuplot-hidden-output-buffer)
- (insert string)
- (when (looking-back "gnuplot> ")
- (with-current-buffer gnuplot-buffer
- (remove-hook 'comint-preoutput-filter-functions
- 'gnuplot-discard-output t))))
- "")
-
-(defun gnuplot-send-hiding-output (string)
- (with-current-buffer gnuplot-buffer
- (add-hook 'comint-preoutput-filter-functions
- 'gnuplot-discard-output nil t))
- (with-current-buffer (get-buffer-create gnuplot-hidden-output-buffer)
- (erase-buffer))
- (comint-send-string gnuplot-process string))
(defun gnuplot-insert-inline-image-output (string)
(save-excursion
@@ -2322,6 +2318,32 @@ gnuplot process buffer will be displayed in a window."
(insert "\n")
(gnuplot-inline-image-set-output)))))))
+;;; Send commands to GNUPLOT silently & without generating an extra prompt
+(defvar gnuplot-hidden-output-buffer " *gnuplot output*")
+
+(defun gnuplot-send-hiding-output (string)
+ "Send STRING to the running Gnuplot process invisibly."
+ (with-current-buffer gnuplot-buffer
+ (add-hook 'comint-preoutput-filter-functions
+ 'gnuplot-discard-output nil t))
+ (with-current-buffer (get-buffer-create gnuplot-hidden-output-buffer)
+ (erase-buffer))
+ (comint-send-string gnuplot-process string))
+
+(defun gnuplot-discard-output (string)
+ ;; Temporary preoutput filter for hiding Gnuplot output & prompt.
+ ;; Accumulates output in a buffer until it finds the next prompt,
+ ;; then removes itself from comint-preoutput-filter-functions.
+ (with-current-buffer
+ (get-buffer-create gnuplot-hidden-output-buffer)
+ (insert string)
+ (when (looking-back "gnuplot> ")
+ (with-current-buffer gnuplot-buffer
+ (remove-hook 'comint-preoutput-filter-functions
+ 'gnuplot-discard-output t))))
+ "")
+
+
;;; --- miscellaneous functions: insert file name, indentation, negation
- [nongnu] elpa/gnuplot cd73487 064/184: Remove other cruft, (continued)
- [nongnu] elpa/gnuplot cd73487 064/184: Remove other cruft, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 76cfd01 043/184: Lots of fixes to grammar, and some bugfixes., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 59f7a94 061/184: Better prompt tracking. Setup inline images on creating comint buffer., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 18dccc2 058/184: Merge branch 'context' into devel, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d4f8c3a 082/184: display progress while running parse tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6da76ee 052/184: Merge branch 'devel', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d26d498 062/184: Added a customization option for gnuplot-inline-image-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d70c94a 065/184: Better docstrings for context-sensitive and inline-image modes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 43effb0 068/184: Add gnuplot-context to makefiles., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f0b1ea7 085/184: Update lists of font-lock keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 70dd22e 060/184: Keyboard shortcut and menu item for toggling inline mode.,
ELPA Syncer <=
- [nongnu] elpa/gnuplot a0fee02 086/184: use `many1' for iteration spec, and tweak its test case, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2dc71de 077/184: Move window-full-height-p up with other compatibility hacks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 3245468 084/184: Fixes to context-sensitive grammar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a290617 079/184: Make info window/frame handling work alike in context and non-context modes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot af7e8de 073/184: Remove references to obsolete kw-compl and hilit19 packages, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 630c945 093/184: Clean up build process to be closer to gnuplot source tree., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c827a90 090/184: Load gnuplot-eldoc only if needed, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot cabfc6c 088/184: fix annoying delay in indentation with blinking paren mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 327d564 091/184: Fix indentation: only outdent a maximum of one closing brace per line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7046fe1 092/184: Misc cleanup and documentation, ELPA Syncer, 2021/08/29