unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* elisp function that evaluates a line up to last character
@ 2019-03-19 17:15 Jason Thomas
  2019-03-19 18:39 ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Thomas @ 2019-03-19 17:15 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-19 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-19 17:15 elisp function that evaluates a line up to last character Jason Thomas
2019-03-19 18:39 ` Eric Abrahamsen
2019-03-19 18:50   ` Eric Abrahamsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).