[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
elisp function that evaluates a line up to last character
From: |
Jason Thomas |
Subject: |
elisp function that evaluates a line up to last character |
Date: |
Tue, 19 Mar 2019 13:15:44 -0400 |
Hello,
I am trying to write a function that will (1) take a new region, defined by
the first character in the current line (where the cursor is) and end the
region at the penultimate character in the same line; and
(2) pass this text to another function (called ess-eval-region).
Basically, I am trying to evaluate some code that ends with a semi-colon,
but I need to leave out the semi-colon (during evaluation). Here is what I
have so far (at the end, I try to bind this function to <C-return> and
activate
this binding in ess mode):
(defun my-stata-eval-delim-line (&optional beg end)
(interactive)
(let ((beg (cond (beg beg)
((region-active-p)
(region-beginning))
(t (line-beginning-position))))
(end (cond (end end)
((region-active-p)
(copy-marker (region-end))
(backward-char))
(t (line-end-position)))))
(ess-eval-region beg end)))
(eval-after-load 'ess-stata-mode
'(define-key ess-mode-map "<C-return>"
'my-stata-eval-delim-line))
but I keep getting an error when I try to use the function on the following
line:
ds;
"Wrong number of arguments: (3 . 5), 2"
Any suggestions/hints about what I am doing wrong (I'm sure there is a long
list)
is greatly appreciated!
Thanks in advance,
Jason
- elisp function that evaluates a line up to last character,
Jason Thomas <=