|
From: Elias A. <eli...@gm...> - 2014-03-05 15:03:07
|
Hi,
In gnuplot-mode, ‘gnuplot-send-line-to-gnuplot’ (C-c C-l) helpfully
searches forward to the end of a continued line. However, I thought it
would be even more helpful to also search backward to the beginning of
the logical line.
So below, you will find a version of the function that does that.
HTH,
Elias
PS: My knowledge of Emacs Lisp is very incomplete …
PPS: gnuplot-mode redefines C-m to newline-and-indent. This makes it
awkward to get a newline without any indention. In my experience, most
Emacs modes use C-j for “smart newline” (whatever that may mean in the
mode's context) but leave C-m to mean plain newline.
(defun gnuplot-send-line-to-gnuplot ()
"Sends the current line to the gnuplot program.
Respects continuation lines.
This sets `gnuplot-recently-sent' to 'line."
(interactive)
(cond ((equal major-mode 'gnuplot-mode)
(let (start
end
;(start (save-excursion (beginning-of-line)
(point-marker)))
;(end (save-excursion (beginning-of-line 2) (point-marker)))
)
(save-excursion
(end-of-line 0)
(if (not (looking-at "^$")) (backward-char 1))
(while (looking-at "\\\\") ; go to beginning of first
continued line
(end-of-line 0)
(if (not (looking-at "^$")) (backward-char 1)))
(next-line)
(beginning-of-line)
(setq start (point-marker)))
(save-excursion
(goto-char start)
(end-of-line)
(backward-char 1)
(while (looking-at "\\\\") ; go to end of last continuation line
(end-of-line 2)
(backward-char 1))
(beginning-of-line 2)
(setq end (point-marker)))
(if (not (string-match "\\`\\s-*\\'"
(buffer-substring-no-properties start end)))
(gnuplot-send-region-to-gnuplot start end 'line))
end))
(t
(message "You can only send lines in gnuplot-mode buffers to gnuplot.")
nil)))
|