|
From: James R. V. Z. <jr...@co...> - 2005-01-10 22:36:12
|
--------------------------------------------------------------
Insert your description of the gnuplot-mode bug here.
Please be as specific as possible.
There are several known shortcomings of gnuplot-mode.
Many of these have to do with the complicated and inconsistent
syntax of gnuplot itself. See the document string for the
function `gnuplot-mode' (use `C-h f') for details.
Note that this bug report form should be used for problems
with gnuplot-mode only. Problems with gnuplot itself should
be addressed directly to the developers of gnuplot.
The maintainer of gnuplot-mode will not field questions about
gnuplot itself. Thank you.
--------------------------------------------------------------
Bruce Ravel -
Thanks for writing gnuplot.el! I assume you're still maintaining it.
gnuplot allows commands to be continued on following lines, but
gnuplot-mode doesn't automate backslashification (as it does in
cc-mode or make-mode). I suggest the changes below, which I stole
from make-mode.
By the way, sh-mode should also automate backslashification, and there
are probably other languages that follow the same convention. It
seems to me we need a generic backslash-region command that could be
invoked by any of the appropriate modes. On the other hand, there are
some differences between c-backslash-region and
makefile-backslash-region which I could not understand and which
prevent a common implementation. (I'm not really much of an elisp
programmer. You'll probably want to check that the difference isn't
important for gnuplot scripts, or else that I picked the right version
by chance :-)
- Jim Van Zandt
--- gnuplot.el 2004-04-10 10:42:33.000000000 -0400
+++ ../../../gnuplot.el 2005-01-10 17:15:13.000000000 -0500
@@ -633,6 +633,7 @@
(define-key gnuplot-mode-map "\C-c\C-u" 'gnuplot-bug-report)
(define-key gnuplot-mode-map "\C-c\C-v" 'gnuplot-send-line-and-forward)
(define-key gnuplot-mode-map "\C-c\C-z" 'gnuplot-customize)
+ (define-key gnuplot-mode-map "\C-c\C-\\" 'gnuplot-backslash-region)
(define-key gnuplot-mode-map "\M-\r" 'gnuplot-complete-keyword)
(define-key gnuplot-mode-map "\M-\t" 'gnuplot-complete-keyword)
(define-key gnuplot-mode-map "\C-i" 'indent-for-tab-command)
@@ -1137,6 +1138,16 @@
(const :tag "No toolbar" nil))
:group 'gnuplot-toolbar)
+(defcustom gnuplot-backslash-column 48
+ "*Column in which `gnuplot-backslash-region' inserts backslashes."
+ :type 'integer
+ :group 'gnuplot)
+
+(defcustom gnuplot-backslash-align t
+ "*If non-nil, `gnuplot-backslash-region' will align backslashes."
+ :type 'boolean
+ :group 'gnuplot)
+
(defvar gnuplot-toolbar-location "")
(defun gnuplot-toolbar-setup-toolbar (toolbar)
@@ -2150,6 +2161,76 @@
(customize-group "gnuplot")
(message "The Custom library is not installed.")))
+;; Backslashification. Stolen from make-mode.el.
+
+(defun gnuplot-backslash-region (from to delete-flag)
+ "Insert, align, or delete end-of-line backslashes on the lines in the region.
+With no argument, inserts backslashes and aligns existing backslashes.
+With an argument, deletes the backslashes.
+
+This function does not modify the last line of the region if the region ends
+right at the start of the following line; it does not modify blank lines
+at the start of the region. So you can put the region around an entire
+gnuplot command and conveniently use this command."
+ (interactive "r\nP")
+ (save-excursion
+ (goto-char from)
+ (let ((column gnuplot-backslash-column)
+ (endmark (make-marker)))
+ (move-marker endmark to)
+ ;; Compute the smallest column number past the ends of all the lines.
+ (if gnuplot-backslash-align
+ (progn
+ (if (not delete-flag)
+ (while (< (point) to)
+ (end-of-line)
+ (if (= (preceding-char) ?\\)
+ (progn (forward-char -1)
+ (skip-chars-backward " \t")))
+ (setq column (max column (1+ (current-column))))
+ (forward-line 1)))
+ ;; Adjust upward to a tab column, if that doesn't push
+ ;; past the margin.
+ (if (> (% column tab-width) 0)
+ (let ((adjusted (* (/ (+ column tab-width -1) tab-width)
+ tab-width)))
+ (if (< adjusted (window-width))
+ (setq column adjusted))))))
+ ;; Don't modify blank lines at start of region.
+ (goto-char from)
+ (while (and (< (point) endmark) (eolp))
+ (forward-line 1))
+ ;; Add or remove backslashes on all the lines.
+ (while (and (< (point) endmark)
+ ;; Don't backslashify the last line
+ ;; if the region ends right at the start of the next line.
+ (save-excursion
+ (forward-line 1)
+ (< (point) endmark)))
+ (if (not delete-flag)
+ (gnuplot-append-backslash column)
+ (gnuplot-delete-backslash))
+ (forward-line 1))
+ (move-marker endmark nil))))
+
+(defun gnuplot-append-backslash (column)
+ (end-of-line)
+ ;; Note that "\\\\" is needed to get one backslash.
+ (if (= (preceding-char) ?\\)
+ (progn (forward-char -1)
+ (delete-horizontal-space)
+ (indent-to column (if gnuplot-backslash-align nil 1)))
+ (indent-to column (if gnuplot-backslash-align nil 1))
+ (insert "\\")))
+
+(defun gnuplot-delete-backslash ()
+ (end-of-line)
+ (or (bolp)
+ (progn
+ (forward-char -1)
+ (if (looking-at "\\\\")
+ (delete-region (1+ (point))
+ (progn (skip-chars-backward " \t") (point)))))))
;;; --- help from the info file, keyword list + completion, insert function
Emacs : GNU Emacs 21.3.1 (i386-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2004-10-16 on raven, modified by Debian
Package: gnuplot-mode (version 0.6.0.vz)
current state:
==============
(setq
gnuplot-mode-hook nil
gnuplot-load-hook nil
gnuplot-after-plot-hook '(gnuplot-trim-gnuplot-buffer)
gnuplot-info-hook nil
gnuplot-comint-setup-hook nil
gnuplot-program "gnuplot"
gnuplot-program-version "4.0"
gnuplot-process-name "gnuplot"
gnuplot-gnuplot-buffer "plot.gp"
gnuplot-display-process 'window
gnuplot-info-display 'window
gnuplot-echo-command-line-flag t
gnuplot-insertions-show-help-flag nil
gnuplot-delay 0.01
gnuplot-quote-character "'"
gnuplot-keywords-when 'deferred
gnuplot-toolbar-display-flag nil
gnuplot-toolbar-use-toolbar nil
gnuplot-gui-popup-flag nil
gnuplot-gui-frame-plist '(height 18 width 65 border-width 0 user-position t
top 150 left 150 internal-border-width 0
unsplittable t default-toolbar-visible-p nil
has-modeline-p nil menubar-visible-p nil)
gnuplot-gui-frame-parameters '((height . 18) (width . 65) (user-position . t)
(top . 150) (left . 150) (border-width . 0)
(menu-bar-lines . 0) (unsplittable . t))
gnuplot-gui-fontname-list '(" " "\"Helvetica\"" "\"Times-Roman\"")
gnuplot-gui-plot-splot-fit-style 'simple
gnuplot-comint-recent-buffer #<buffer vel.dem>
gnuplot-version "0.6.0.vz"
Info-directory-list nil
exec-path '("/usr/local/bin" "/usr/bin" "/bin" "/usr/bin/X11" "/usr/games"
"/home/jrv/bin" "/usr/local/netpbm" "/usr/bin/mh"
"/usr/lib/emacs/21.3/i386-linux")
features '(sendmail reporter newcomment view gnuplot-gui cl cl-19 wid-edit
image gnuplot info-look info rmail compile mailcrypt rfc822 comint
tempo w3-cus url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-util url-parse url-auto timezone
url-vars mailcap mail-parse rfc2045 rfc2047 gnus-util nnheader
mail-utils qp rfc2231 ietf-drums mm-util mule-util time-date
parse-time mail-prsvr xml-parse doxymacs debian-el
debian-el-loaddefs psgml-init mailcrypt-init dpkg-dev-el
dpkg-dev-el-loaddefs xcscope ring easymenu tex-site calc-init
disp-table ediff-hook vc-hooks lisp-float-type lisp-mode page
menu-bar timer select scroll-bar mldrag mouse facemenu faces
cus-face frame ucs-tables misc-lang vietnamese tibetan thai lao
korean japanese hebrew greek romanian slovak czech european
ethiopic devanagari indian cyrillic chinese case-table help
overlay md5 base64 format mule env backquote custom widget
x-toolkit)
)
|