Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the line number to a variable in Emacs

Tags:

elisp

I am trying to set the current line number to a variable in Elisp but keep getting a void-variable error!

The code is:

(setq x what-line)

I'd also like to set the total number of lines in the buffer to a variable as well, but get the same error?!

like image 524
marktucks Avatar asked Feb 05 '09 10:02

marktucks


1 Answers

(setq x (line-number-at-pos)
      y (line-number-at-pos (point-max)))

How to find out about this kind of thing? Try M-x find-function RET what-line RET to see the source code of what-line. Reading simple.el (the file in which what-line is defined) is a good way to get familiar with elementary Elisp programming.

like image 189
Jouni K. Seppänen Avatar answered Sep 20 '22 17:09

Jouni K. Seppänen