@@ -722,28 +722,27 @@ opening an argument-setting popup.")
722722
723723(defun gnuplot--setup-menubar ()
724724 " Initial setup of gnuplot and insertions menus."
725- (if gnuplot-insertions-menu-flag ; set up insertions menu
726- (progn
727- (setq gnuplot-insertions-top
728- '(" insert set expression" " ---" ))
729- (setq gnuplot-insertions-menu
730- (append (list " Insertions" )
731- gnuplot-insertions-top
732- (list gnuplot-insertions-adornments)
733- (list gnuplot-insertions-plot-options)
734- (list gnuplot-insertions-terminal)
735- (list gnuplot-insertions-x-axis)
736- (list gnuplot-insertions-y-axis)
737- (list gnuplot-insertions-z-axis)
738- (list gnuplot-insertions-x2-axis)
739- (list gnuplot-insertions-y2-axis)
740- (list gnuplot-insertions-parametric-plots)
741- (list gnuplot-insertions-polar-plots)
742- (list gnuplot-insertions-surface-plots)
743- gnuplot-insertions-bottom))
744- (easy-menu-define gnuplot-mode-insertions-menu gnuplot-mode-map
745- " Insertions menu used in Gnuplot-mode"
746- gnuplot-insertions-menu)))
725+ (when gnuplot-insertions-menu-flag
726+ (setq gnuplot-insertions-top
727+ '(" insert set expression" " ---" ))
728+ (setq gnuplot-insertions-menu
729+ (append (list " Insertions" )
730+ gnuplot-insertions-top
731+ (list gnuplot-insertions-adornments)
732+ (list gnuplot-insertions-plot-options)
733+ (list gnuplot-insertions-terminal)
734+ (list gnuplot-insertions-x-axis)
735+ (list gnuplot-insertions-y-axis)
736+ (list gnuplot-insertions-z-axis)
737+ (list gnuplot-insertions-x2-axis)
738+ (list gnuplot-insertions-y2-axis)
739+ (list gnuplot-insertions-parametric-plots)
740+ (list gnuplot-insertions-polar-plots)
741+ (list gnuplot-insertions-surface-plots)
742+ gnuplot-insertions-bottom))
743+ (easy-menu-define gnuplot-mode-insertions-menu gnuplot-mode-map
744+ " Insertions menu used in Gnuplot-mode"
745+ gnuplot-insertions-menu))
747746 (easy-menu-define ; set up gnuplot menu
748747 gnuplot-mode-menu gnuplot-mode-map " Menu used in gnuplot-mode"
749748 gnuplot-menu))
@@ -1019,15 +1018,14 @@ called by this function after all of STRING is sent to gnuplot."
10191018 (setq gnuplot-comint-recent-buffer (current-buffer ))
10201019
10211020 ; ; Create a gnuplot frame if needed
1022- (if (equal gnuplot-display-process 'frame )
1023- (or (and gnuplot-process-frame
1024- (frame-live-p gnuplot-process-frame))
1025- (let ((frame (selected-frame )))
1026- (setq gnuplot-process-frame (make-frame ))
1027- (select-frame gnuplot-process-frame)
1028- (switch-to-buffer gnuplot-buffer)
1029- (delete-other-windows )
1030- (select-frame frame))))
1021+ (when (and (equal gnuplot-display-process 'frame )
1022+ (not (frame-live-p gnuplot-process-frame)))
1023+ (let ((frame (selected-frame )))
1024+ (setq gnuplot-process-frame (make-frame ))
1025+ (select-frame gnuplot-process-frame)
1026+ (switch-to-buffer gnuplot-buffer)
1027+ (delete-other-windows )
1028+ (select-frame frame)))
10311029
10321030 (let ((list (gnuplot--split-string string)))
10331031 (with-current-buffer (get-buffer gnuplot-buffer)
@@ -1071,7 +1069,7 @@ useful for function in `gnuplot-after-plot-hook'."
10711069 (let (string (txt (or text 'region )))
10721070 (cond ((equal major-mode 'gnuplot-mode )
10731071 (setq string (buffer-substring-no-properties begin end))
1074- (if ( string= (substring string -1 ) " \n " ) ( )
1072+ (unless ( equal (substring string -1 ) " \n " )
10751073 (setq string (concat string " \n " )))
10761074 (gnuplot-send-string-to-gnuplot string txt))
10771075 (t
@@ -1097,9 +1095,9 @@ This sets `gnuplot-recently-sent' to `line'."
10971095 (end-of-line 2 ))
10981096 (beginning-of-line 2 )
10991097 (setq end (point )))
1100- (if ( not (string-match " \\ `\\s-*\\' "
1101- (buffer-substring-no-properties start end) ))
1102- (gnuplot-send-region-to-gnuplot start end 'line ))
1098+ (unless (string-match " \\ `\\s-*\\' "
1099+ (buffer-substring-no-properties start end))
1100+ (gnuplot-send-region-to-gnuplot start end 'line ))
11031101 end))
11041102 (t
11051103 (message " You can only send lines in gnuplot-mode buffers to gnuplot. " )
@@ -1208,13 +1206,13 @@ file visited by the script buffer."
12081206 " Trim lines from the beginning of the *gnuplot* buffer.
12091207This keeps that buffer from growing excessively in size. Normally,
12101208this function is attached to `gnuplot-after-plot-hook' "
1211- (if (> gnuplot-buffer-max-size 0 )
1212- (with-current-buffer gnuplot-buffer
1213- (let ((gnuplot-lines (count-lines (point-min ) (point-max ))))
1214- (dotimes (_n (- gnuplot-lines gnuplot-buffer-max-size))
1215- (goto-char (point-min ))
1216- (delete-region (line-beginning-position ) (1+ (line-end-position ))))
1217- (goto-char (point-max ))))))
1209+ (when (> gnuplot-buffer-max-size 0 )
1210+ (with-current-buffer gnuplot-buffer
1211+ (let ((gnuplot-lines (count-lines (point-min ) (point-max ))))
1212+ (dotimes (_n (- gnuplot-lines gnuplot-buffer-max-size))
1213+ (goto-char (point-min ))
1214+ (delete-region (line-beginning-position ) (1+ (line-end-position ))))
1215+ (goto-char (point-max ))))))
12181216
12191217
12201218; ;; --- functions controlling the gnuplot process
@@ -1318,18 +1316,15 @@ buffer."
13181316 " Prevent the Gnuplot prompt from being deleted or overwritten.
13191317STRING is the text as originally inserted in the comint buffer."
13201318 (save-excursion
1321- (let ((b (progn
1322- (goto-char (point-max ))
1323- (beginning-of-line )
1324- (point )))
1325- e)
1326- (if (re-search-forward gnuplot-prompt-regexp (point-max ) t )
1327- (progn
1328- (setq e (point ))
1329- (put-text-property b e 'rear-nonsticky '(read-only intangible face))
1330- (put-text-property b e 'intangible t )
1331- ; ;(put-text-property b e 'read-only t)
1332- )))))
1319+ (goto-char (point-max ))
1320+ (beginning-of-line )
1321+ (let ((b (point )) e)
1322+ (when (re-search-forward gnuplot-prompt-regexp (point-max ) t )
1323+ (setq e (point ))
1324+ (put-text-property b e 'rear-nonsticky '(read-only intangible face))
1325+ (put-text-property b e 'intangible t )
1326+ ; ;(put-text-property b e 'read-only t)
1327+ ))))
13331328
13341329(defun gnuplot--close-down ()
13351330 " Tidy up when deleting the gnuplot buffer."
@@ -1353,11 +1348,10 @@ This is very similar to `comint-delchar-or-maybe-eof'."
13531348 (if (and gnuplot-process
13541349 (eq (process-status gnuplot-process) 'run ))
13551350 (kill-process gnuplot-process))
1356- (if (and gnuplot-buffer (get-buffer gnuplot-buffer))
1357- (progn
1358- (if (one-window-p ) ()
1359- (delete-window (get-buffer-window gnuplot-buffer)))
1360- (kill-buffer gnuplot-buffer)))
1351+ (when (and gnuplot-buffer (get-buffer gnuplot-buffer))
1352+ (if (one-window-p ) ()
1353+ (delete-window (get-buffer-window gnuplot-buffer)))
1354+ (kill-buffer gnuplot-buffer))
13611355 (setq gnuplot-process nil
13621356 gnuplot-buffer nil ))
13631357
@@ -1372,8 +1366,7 @@ gnuplot process buffer will be displayed in a window."
13721366 (cond ((equal gnuplot-display-process 'window )
13731367 (switch-to-buffer-other-window gnuplot-buffer))
13741368 ((equal gnuplot-display-process 'frame )
1375- (or (and gnuplot-process-frame
1376- (frame-live-p gnuplot-process-frame))
1369+ (or (frame-live-p gnuplot-process-frame)
13771370 (setq gnuplot-process-frame (make-frame )))
13781371 (raise-frame gnuplot-process-frame)
13791372 (select-frame gnuplot-process-frame)
@@ -1627,7 +1620,7 @@ If specify POS, move POS before execution."
16271620(defun gnuplot--beginning-of-defun (&optional arg )
16281621 " We also treat a block of continuation lines as a `defun' .
16291622ARG is optional arg."
1630- (if ( not arg) (setq arg 1 ))
1623+ (unless arg (setq arg 1 ))
16311624 (if (> arg 0 )
16321625 (catch 'bob ; go to beginning of ARGth prev. defun
16331626 (dotimes (_n arg)
@@ -1826,8 +1819,7 @@ called."
18261819 (- (/ (frame-height ) 2 ) (window-height )))))))
18271820
18281821 (frame
1829- (unless (and gnuplot-info-frame
1830- (frame-live-p gnuplot-info-frame))
1822+ (unless (frame-live-p gnuplot-info-frame)
18311823 (setq gnuplot-info-frame (make-frame )))
18321824 (select-frame gnuplot-info-frame)
18331825 (raise-frame gnuplot-info-frame)
@@ -1845,13 +1837,12 @@ shown."
18451837 (interactive )
18461838 (insert string)
18471839 (let ((topic string) term )
1848- (if (string-match
1849- " \\ (set\\ |show\\ )[ \t ]+\\ ([^ \t ]+\\ )\\ (\\ s-+\\ ([^ \t ]+\\ )\\ )?"
1850- string)
1851- (progn
1852- (setq topic (downcase (match-string 2 string))
1853- term (match-string 4 string))
1854- (if (string= topic " terminal" ) (setq topic (downcase term )))))
1840+ (when (string-match
1841+ " \\ (set\\ |show\\ )[ \t ]+\\ ([^ \t ]+\\ )\\ (\\ s-+\\ ([^ \t ]+\\ )\\ )?"
1842+ string)
1843+ (setq topic (downcase (match-string 2 string))
1844+ term (match-string 4 string))
1845+ (if (equal topic " terminal" ) (setq topic (downcase term ))))
18551846 (cond ((bound-and-true-p gnuplot-gui-popup-flag)
18561847 (gnuplot-gui-set-options-and-insert))
18571848 (gnuplot-insertions-show-help-flag
0 commit comments