emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnuplot a290617 079/184: Make info window/frame handling w


From: ELPA Syncer
Subject: [nongnu] elpa/gnuplot a290617 079/184: Make info window/frame handling work alike in context and non-context modes
Date: Sun, 29 Aug 2021 11:03:19 -0400 (EDT)

branch: elpa/gnuplot
commit a290617eef82b6c2e3383de2b203c769902f78a4
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>

    Make info window/frame handling work alike in context and non-context modes
    
    - Also make sure that visiting a particular info node works in pre-23
      emacs versions, where (info "(gnuplot)node") doesn't work: see
      `gnuplot--find-info-node'
---
 .gitignore         |  1 +
 gnuplot-context.el | 30 ++++++++++-----------
 gnuplot.el         | 77 ++++++++++++++++++++++++++++++------------------------
 3 files changed, 59 insertions(+), 49 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4f4afcc..b33132c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@
 /Makefile
 /config.cache
 /config.status
+/info-look.el
diff --git a/gnuplot-context.el b/gnuplot-context.el
index d125525..07632bd 100644
--- a/gnuplot-context.el
+++ b/gnuplot-context.el
@@ -248,9 +248,11 @@
 ;; It would be possible to provide more helpful ElDoc strings for
 ;; sub-parts of complicated options like "cntrparam". This is a time
 ;; and maintenance issue rather than a technical one.
-;;
-;;
 
+;;; Code:
+
+
+;; Library dependencies
 (eval-when-compile
   (require 'cl)
   (require 'advice)
@@ -282,11 +284,7 @@ These have to be compiled from the Gnuplot source tree 
using
 
   (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))))
+      `(with-current-buffer ,buffer ,variable))))
 
 
 ;;;; Interface to turning the mode on and off
@@ -2237,14 +2235,16 @@ there."
       (let ((info
             (info-lookup-interactive-arguments 'symbol)))
        (setq gnuplot-info-at-point (car info))))
-  (and gnuplot-info-at-point
-       (info-other-window (format "(gnuplot)%s" gnuplot-info-at-point))))
-
-(defun gnuplot-info-look-guess ()
-  (gnuplot-parse-at-point nil)
-  gnuplot-info-at-point)
-
-
+  (when gnuplot-info-at-point
+    (gnuplot--find-info-node gnuplot-info-at-point)))
+
+(defun gnuplot--find-info-node (node)
+  (save-window-excursion
+    (if (>= emacs-major-version 23)
+        (info (format "(gnuplot)%s" node))
+      (info)
+      (Info-find-node "gnuplot" node)))
+  (gnuplot--adjust-info-display))
 
 
 ;;; Some context-sensitive hacks 
diff --git a/gnuplot.el b/gnuplot.el
index 65ca228..9740fd7 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -2849,12 +2849,10 @@ completion."
 
 (defun gnuplot-info-lookup-symbol (symbol &optional mode)
   "Wrapper for `info-lookup-symbol'.
-Takes SYMBOL and MODE as arguments exactly as `info-lookup-symbol'.
-After doing the info lookup, this displays the info file in a window
-frame as specified by the value of `gnuplot-info-display'.  If
-`gnuplot-info-display' is 'window, then the window will be shrunk to
-the size of the info entry if it is smaller than half the height of
-the frame."
+Takes SYMBOL and MODE as arguments exactly as
+`info-lookup-symbol'.  After doing the info lookup, calls
+`gnuplot--adjust-info-display' to display the info buffer
+according to the value of `gnuplot-info-display'."
   (interactive
    (cond (gnuplot-keywords
          (info-lookup-interactive-arguments 'symbol))
@@ -2865,34 +2863,45 @@ the frame."
          (list nil (message
        "Help is not available.  The gnuplot info file could not be found.")))))
 
-  (if (and (featurep 'info-look) gnuplot-keywords)
-      (let ((buff (current-buffer))
-           (info-lookup-other-window-flag
-            (if gnuplot-info-display t nil)))
-       (if symbol () (setq symbol "Commands"))
-       (info-lookup-symbol symbol mode)
-       (cond ((equal gnuplot-info-display 'window) 
-              ;; Adjust window height only if the frame is split 
-              ;; horizontally, so as not to mess up the minibuffer <jjo>
-              ;; we can't use shrink-window-if-larger-than-buffer here
-              ;; because it doesn't work with Info mode's narrowing
-              (with-selected-window (get-buffer-window "*info*")
-                (unless (gnuplot-window-full-height-p)
-                  (enlarge-window
-                   (min (- (count-lines (point-min) (point-max)) 
(window-height) -1)
-                        (- (/ (frame-height) 2) (window-height)))))))
-
-             ((equal gnuplot-info-display 'frame)
-              (switch-to-buffer buff)
-              (delete-other-windows)
-              (or (and gnuplot-info-frame
-                       (frame-live-p gnuplot-info-frame))
-                  (setq gnuplot-info-frame (make-frame)))
-              (select-frame gnuplot-info-frame)
-              (raise-frame gnuplot-info-frame)
-              (if gnuplot-xemacs-p (setq toolbar-info-frame 
gnuplot-info-frame))
-              (switch-to-buffer "*info*"))))))
-
+  (when (and (featurep 'info-look) gnuplot-keywords)
+    (unless symbol (setq symbol "Commands"))
+    (save-window-excursion
+      (info-lookup-symbol symbol mode))
+    (gnuplot--adjust-info-display)))
+
+(defun gnuplot--adjust-info-display ()
+  "Displays the *info* buffer in a window or frame as specified
+by the value of `gnuplot-info-display'.  If
+`gnuplot-info-display' is 'window, then the window will be shrunk
+to the size of the info entry if it is smaller than half the
+height of the frame.
+
+The *info* buffer should already exist when this function is
+called."
+  (case gnuplot-info-display
+    (window
+     (switch-to-buffer-other-window "*info*")
+     ;; Adjust window height only if the frame is split 
+     ;; horizontally, so as not to mess up the minibuffer <jjo>
+     ;; we can't use shrink-window-if-larger-than-buffer here
+     ;; because it doesn't work with Info mode's narrowing
+     (with-selected-window (get-buffer-window "*info*")
+       (unless (gnuplot-window-full-height-p)
+         (enlarge-window
+          (min (- (count-lines (point-min) (point-max)) (window-height) -1)
+               (- (/ (frame-height) 2) (window-height)))))))
+
+    (frame
+     (unless (and gnuplot-info-frame
+                  (frame-live-p gnuplot-info-frame))
+       (setq gnuplot-info-frame (make-frame)))
+     (select-frame gnuplot-info-frame)
+     (raise-frame gnuplot-info-frame)
+     (if gnuplot-xemacs-p (setq toolbar-info-frame gnuplot-info-frame))
+     (switch-to-buffer "*info*"))
+
+    (t
+     (switch-to-buffer "*info*"))))
 
 (defun gnuplot-insert (string)
   "Insert STRING at point and display help for for STRING.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]