5858; ;; Code:
5959
6060(require 'gnuplot )
61- (eval-and-compile
62- (condition-case ()
63- (progn
64- (require 'widget )
65- (require 'wid-edit ))
66- (error nil )))
61+ (require 'widget )
62+ (require 'wid-edit )
6763(require 'cl-lib )
68- (eval-when-compile ; suppress some compiler warnings
69- (defvar gnuplot-quote-character nil )
70- (defvar gnuplot-info-display nil )
71- (defvar gnuplot-mode-map nil ))
72-
73- ; ; (eval-when-compile
74- ; ; (require 'wid-edit))
75-
76- (eval-and-compile ; I need this!
77- (if (fboundp 'split-string )
78- ()
79- (defun split-string (string &optional pattern )
80- " Return a list of substrings of STRING which are separated by PATTERN.
81- If PATTERN is omitted, it defaults to \" [ \\ f\\ t\\ n\\ r\\ v]+\" ."
82- (or pattern
83- (setq pattern " [ \f\t\n\r\v ]+" ))
84- ; ; The FSF version of this function takes care not to cons in case
85- ; ; of infloop. Maybe we should synch?
86- (let (parts (start 0 ))
87- (while (string-match pattern string start)
88- (setq parts (cons (substring string start (match-beginning 0 )) parts)
89- start (match-end 0 )))
90- (nreverse (cons (substring string start) parts)))) ))
91-
9264
9365
9466; ;; customizable variables
@@ -860,10 +832,9 @@ EVENT is a mouse event. Bound to \\[gnuplot-gui-mouse-set]
860832Note that \" plot\" , \" splot\" , \" fit\" , and \" cntrparam\" are not
861833currently supported."
862834 (interactive " @e" )
863- (when (fboundp 'widget-create )
864- (save-excursion
865- (mouse-set-point event)
866- (gnuplot-gui-set-options-and-insert))))
835+ (save-excursion
836+ (mouse-set-point event)
837+ (gnuplot-gui-set-options-and-insert)))
867838
868839(defun gnuplot-gui-get-frame-param (param )
869840 (cdr (assoc param gnuplot-gui-frame-parameters)))
@@ -877,81 +848,80 @@ Determine contents of current line and set up the appropriate GUI
877848frame. Bound to \\ [gnuplot-gui-set-options-and-insert]
878849Note that \" cntrparam\" is not currently supported."
879850 (interactive )
880- (when (fboundp 'widget-create )
881- (let ((begin (gnuplot-point-at-beginning-of-command))
882- (end (save-excursion (end-of-line ) (point-marker )))
883- (termin (concat " \\ (,\\ s-*" (regexp-quote " \\ " ) " \\ |;\\ )" ))
884- (set nil ) (term nil ))
885- (save-excursion
886- ; ; there can be more then one command per line
887- (if (re-search-forward termin end " to_limit" )
888- (progn (backward-char (length (match-string 1 )))
889- (setq end (point-marker ))))
890- (goto-char begin)
891- (skip-syntax-forward " -" end)
892- ; ; various constructions are recognized here. at the end of this
893- ; ; cond, point should be just after the word whose arguments are
894- ; ; to be set
895- (cond ((looking-at " set\\ s-+" )
896- (setq set t )
897- (goto-char (match-end 0 ))
898- (if (looking-at " \\ sw+" ) (goto-char (match-end 0 )))
899- (when (string-match " ^ter" (gnuplot-this-word)) ; terminal?
900- (setq term t )
901- (forward-word 1 ))
902- (when (string-match " ^\\ (da\\ |fu\\ )" (gnuplot-this-word))
903- (unless (looking-at " \\ s-+st" )
904- (insert " style" ) (forward-word 1 ))
905- (forward-word 1 )))
906- ((looking-at (concat " \\ (cd\\ |ca\\ |lo\\ |pa\\ |pr\\ |sa\\ |u\\ )"
907- " \\ w*"
908- " [\\ s-\\ ']" ))
851+ (let ((begin (gnuplot-point-at-beginning-of-command))
852+ (end (save-excursion (end-of-line ) (point-marker )))
853+ (termin (concat " \\ (,\\ s-*" (regexp-quote " \\ " ) " \\ |;\\ )" ))
854+ (set nil ) (term nil ))
855+ (save-excursion
856+ ; ; there can be more then one command per line
857+ (if (re-search-forward termin end " to_limit" )
858+ (progn (backward-char (length (match-string 1 )))
859+ (setq end (point-marker ))))
860+ (goto-char begin)
861+ (skip-syntax-forward " -" end)
862+ ; ; various constructions are recognized here. at the end of this
863+ ; ; cond, point should be just after the word whose arguments are
864+ ; ; to be set
865+ (cond ((looking-at " set\\ s-+" )
866+ (setq set t )
867+ (goto-char (match-end 0 ))
868+ (if (looking-at " \\ sw+" ) (goto-char (match-end 0 )))
869+ (when (string-match " ^ter" (gnuplot-this-word)) ; terminal?
870+ (setq term t )
909871 (forward-word 1 ))
910- ; ;(goto-char (match-end 0)))
911- (t
872+ (when (string-match " ^\\ (da\\ |fu\\ )" (gnuplot-this-word))
873+ (unless (looking-at " \\ s-+st" )
874+ (insert " style" ) (forward-word 1 ))
912875 (forward-word 1 )))
913- (if (> (point ) end) (goto-char end))
914- (let* ((w (gnuplot-this-word))
915- (wd (try-completion w gnuplot-gui-all-types))
916- (word " " ) wrd list )
917- (cond ((equal wd t ) (setq word w))
918- ((equal wd nil ) (setq word w))
919- ((assoc wd gnuplot-gui-all-types) (setq word wd))
920- (t (setq wd nil )))
921- (cond ((equal (string-match " ^\\ s-*$" w) 0 )
922- (message " Blank line " ))
923- ((and wd (stringp word))
924- (gnuplot-gui-correct-command word set term begin)
925- (setq gnuplot-gui-alist nil
926- gnuplot-gui-current-string
927- (buffer-substring-no-properties (point ) end))
928- (gnuplot-gui-set-alist word gnuplot-gui-current-string)
929- (let* ((old-height (gnuplot-gui-get-frame-param 'height ))
930- (old-top (gnuplot-gui-get-frame-param 'top )))
931- (when (or
932- (and (equal gnuplot-gui-plot-splot-fit-style 'complete )
933- (cl-member word '(" plot" " splot" " fit" )
876+ ((looking-at (concat " \\ (cd\\ |ca\\ |lo\\ |pa\\ |pr\\ |sa\\ |u\\ )"
877+ " \\ w*"
878+ " [\\ s-\\ ']" ))
879+ (forward-word 1 ))
880+ ; ;(goto-char (match-end 0)))
881+ (t
882+ (forward-word 1 )))
883+ (if (> (point ) end) (goto-char end))
884+ (let* ((w (gnuplot-this-word))
885+ (wd (try-completion w gnuplot-gui-all-types))
886+ (word " " ) wrd list )
887+ (cond ((equal wd t ) (setq word w))
888+ ((equal wd nil ) (setq word w))
889+ ((assoc wd gnuplot-gui-all-types) (setq word wd))
890+ (t (setq wd nil )))
891+ (cond ((equal (string-match " ^\\ s-*$" w) 0 )
892+ (message " Blank line " ))
893+ ((and wd (stringp word))
894+ (gnuplot-gui-correct-command word set term begin)
895+ (setq gnuplot-gui-alist nil
896+ gnuplot-gui-current-string
897+ (buffer-substring-no-properties (point ) end))
898+ (gnuplot-gui-set-alist word gnuplot-gui-current-string)
899+ (let* ((old-height (gnuplot-gui-get-frame-param 'height ))
900+ (old-top (gnuplot-gui-get-frame-param 'top )))
901+ (when (or
902+ (and (equal gnuplot-gui-plot-splot-fit-style 'complete )
903+ (cl-member word '(" plot" " splot" " fit" )
934904 :test 'string= ))
935- (equal word " test" ))
936- (gnuplot-gui-set-frame-param 'height 32 )
937- (gnuplot-gui-set-frame-param 'top 50 ))
938- (gnuplot-gui-prompt-for-frame word)
939- (when (or
940- (and (equal gnuplot-gui-plot-splot-fit-style 'complete )
941- (cl-member word '(" plot" " splot" " fit" )
905+ (equal word " test" ))
906+ (gnuplot-gui-set-frame-param 'height 32 )
907+ (gnuplot-gui-set-frame-param 'top 50 ))
908+ (gnuplot-gui-prompt-for-frame word)
909+ (when (or
910+ (and (equal gnuplot-gui-plot-splot-fit-style 'complete )
911+ (cl-member word '(" plot" " splot" " fit" )
942912 :test 'string= ))
943- (equal word " test" ))
944- (gnuplot-gui-set-frame-param 'height old-height)
945- (gnuplot-gui-set-frame-param 'top old-top)) ))
946- ((setq wrd (car (all-completions w '((" cntrparam" )))))
947- (message
948- " Setting arguments for %S is currently unsuported in gnuplot-mode"
949- wrd))
950- ((setq list (all-completions w gnuplot-gui-all-types))
951- (message " %S could be one of %S " w list ))
952- (t
953- (message
954- " %S is not a gnuplot command which takes options" w)))) ) )))
913+ (equal word " test" ))
914+ (gnuplot-gui-set-frame-param 'height old-height)
915+ (gnuplot-gui-set-frame-param 'top old-top)) ))
916+ ((setq wrd (car (all-completions w '((" cntrparam" )))))
917+ (message
918+ " Setting arguments for %S is currently unsuported in gnuplot-mode"
919+ wrd))
920+ ((setq list (all-completions w gnuplot-gui-all-types))
921+ (message " %S could be one of %S " w list ))
922+ (t
923+ (message
924+ " %S is not a gnuplot command which takes options" w)))) )))
955925
956926(defun gnuplot-gui-toggle-popup ()
957927 (interactive )
0 commit comments