[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot ffe6c66 059/184: First shot at implementing inline
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot ffe6c66 059/184: First shot at implementing inline plot images in process buffer |
Date: |
Sun, 29 Aug 2021 11:03:15 -0400 (EDT) |
branch: elpa/gnuplot
commit ffe6c668a52c10b0a535aabc981ef22d7cc2a05f
Author: Jonathan Oddie <j.j.oddie@gmail.com>
Commit: joddie <jonxfield@gmail.com>
First shot at implementing inline plot images in process buffer
---
gnuplot.el | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/gnuplot.el b/gnuplot.el
index a58e044..071edd3 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -2255,6 +2255,74 @@ gnuplot process buffer will be displayed in a window."
(switch-to-buffer gnuplot-buffer))))
+;;; --- inline image stuff <JJO>
+(defvar gnuplot-inline-image-filename nil)
+
+(defvar gnuplot-inline-image-mode 0)
+
+(defvar gnuplot-inline-image-timestamp nil)
+
+(defun gnuplot-inline-image-mode (&optional enable)
+ (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."))))
+
+(defun gnuplot-inline-image-set-output ()
+ (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
+ (goto-char (point-max))
+ (beginning-of-line)
+ (when (looking-at "^gnuplot> ")
+ (let* ((filename gnuplot-inline-image-filename)
+ (size (nth 7 (file-attributes filename))))
+ (if (and size (> size 0))
+ (let ((image (create-image filename)))
+ (beginning-of-line)
+ (insert-image image)
+ (insert "\n")
+ (gnuplot-inline-image-set-output)))))))
+
+
;;; --- miscellaneous functions: insert file name, indentation, negation
(defun gnuplot-insert-filename ()
- [nongnu] elpa/gnuplot 8d367f5 028/184: Better assignment-matching regexp (?), (continued)
- [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, 2021/08/29
- [nongnu] elpa/gnuplot ffe6c66 059/184: First shot at implementing inline plot images in process buffer,
ELPA Syncer <=
- [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
- [nongnu] elpa/gnuplot c520e94 075/184: Remove a redundant check for gnuplot-keywords-pending, ELPA Syncer, 2021/08/29