@@ -722,28 +722,27 @@ opening an argument-setting popup.")
722
722
723
723
(defun gnuplot--setup-menubar ()
724
724
" 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))
747
746
(easy-menu-define ; set up gnuplot menu
748
747
gnuplot-mode-menu gnuplot-mode-map " Menu used in gnuplot-mode"
749
748
gnuplot-menu))
@@ -1019,15 +1018,14 @@ called by this function after all of STRING is sent to gnuplot."
1019
1018
(setq gnuplot-comint-recent-buffer (current-buffer ))
1020
1019
1021
1020
; ; 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)))
1031
1029
1032
1030
(let ((list (gnuplot--split-string string)))
1033
1031
(with-current-buffer (get-buffer gnuplot-buffer)
@@ -1071,7 +1069,7 @@ useful for function in `gnuplot-after-plot-hook'."
1071
1069
(let (string (txt (or text 'region )))
1072
1070
(cond ((equal major-mode 'gnuplot-mode )
1073
1071
(setq string (buffer-substring-no-properties begin end))
1074
- (if ( string= (substring string -1 ) " \n " ) ( )
1072
+ (unless ( equal (substring string -1 ) " \n " )
1075
1073
(setq string (concat string " \n " )))
1076
1074
(gnuplot-send-string-to-gnuplot string txt))
1077
1075
(t
@@ -1097,9 +1095,9 @@ This sets `gnuplot-recently-sent' to `line'."
1097
1095
(end-of-line 2 ))
1098
1096
(beginning-of-line 2 )
1099
1097
(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 ))
1103
1101
end))
1104
1102
(t
1105
1103
(message " You can only send lines in gnuplot-mode buffers to gnuplot. " )
@@ -1208,13 +1206,13 @@ file visited by the script buffer."
1208
1206
" Trim lines from the beginning of the *gnuplot* buffer.
1209
1207
This keeps that buffer from growing excessively in size. Normally,
1210
1208
this 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 ))))))
1218
1216
1219
1217
1220
1218
; ;; --- functions controlling the gnuplot process
@@ -1318,18 +1316,15 @@ buffer."
1318
1316
" Prevent the Gnuplot prompt from being deleted or overwritten.
1319
1317
STRING is the text as originally inserted in the comint buffer."
1320
1318
(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
+ ))))
1333
1328
1334
1329
(defun gnuplot--close-down ()
1335
1330
" Tidy up when deleting the gnuplot buffer."
@@ -1353,11 +1348,10 @@ This is very similar to `comint-delchar-or-maybe-eof'."
1353
1348
(if (and gnuplot-process
1354
1349
(eq (process-status gnuplot-process) 'run ))
1355
1350
(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))
1361
1355
(setq gnuplot-process nil
1362
1356
gnuplot-buffer nil ))
1363
1357
@@ -1372,8 +1366,7 @@ gnuplot process buffer will be displayed in a window."
1372
1366
(cond ((equal gnuplot-display-process 'window )
1373
1367
(switch-to-buffer-other-window gnuplot-buffer))
1374
1368
((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)
1377
1370
(setq gnuplot-process-frame (make-frame )))
1378
1371
(raise-frame gnuplot-process-frame)
1379
1372
(select-frame gnuplot-process-frame)
@@ -1627,7 +1620,7 @@ If specify POS, move POS before execution."
1627
1620
(defun gnuplot--beginning-of-defun (&optional arg )
1628
1621
" We also treat a block of continuation lines as a `defun' .
1629
1622
ARG is optional arg."
1630
- (if ( not arg) (setq arg 1 ))
1623
+ (unless arg (setq arg 1 ))
1631
1624
(if (> arg 0 )
1632
1625
(catch 'bob ; go to beginning of ARGth prev. defun
1633
1626
(dotimes (_n arg)
@@ -1826,8 +1819,7 @@ called."
1826
1819
(- (/ (frame-height ) 2 ) (window-height )))))))
1827
1820
1828
1821
(frame
1829
- (unless (and gnuplot-info-frame
1830
- (frame-live-p gnuplot-info-frame))
1822
+ (unless (frame-live-p gnuplot-info-frame)
1831
1823
(setq gnuplot-info-frame (make-frame )))
1832
1824
(select-frame gnuplot-info-frame)
1833
1825
(raise-frame gnuplot-info-frame)
@@ -1845,13 +1837,12 @@ shown."
1845
1837
(interactive )
1846
1838
(insert string)
1847
1839
(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 ))))
1855
1846
(cond ((bound-and-true-p gnuplot-gui-popup-flag)
1856
1847
(gnuplot-gui-set-options-and-insert))
1857
1848
(gnuplot-insertions-show-help-flag
0 commit comments