LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem trying to test some LISP code in an Emacs buffer... (https://www.linuxquestions.org/questions/linux-newbie-8/problem-trying-to-test-some-lisp-code-in-an-emacs-buffer-850995/)

bzimmerly 12-17-2010 11:42 PM

Problem trying to test some LISP code in an Emacs buffer...
 
Hi LQ!

The problem is easy to explain, but what is the solution?

Visit this page: http://www.gnu.org/software/emacs/el...itting-Windows

Open emacs and enter the code into a scratch buffer.

Try to "Evaluate (the) Buffer" and here is what I get:

"Symbol's value as variable is void: =>"

I tried searching for the answer on Google but what I found doesn't make much sense to me. Does anyone see why this won't work? Thanks for any and all answers!

Sincerely,
- Bill

P.S. I am using Emacs v23.2.1 on Ubuntu Linux 10.04.

ntubski 12-18-2010 12:48 AM

The lines starting with ⇒ aren't code, they just show the return value of the code.

bgoodr 12-18-2010 12:50 AM

Quote:

Originally Posted by bzimmerly (Post 4195523)
Hi LQ!
Open emacs and enter the code into a scratch buffer.

What did you type into the buffer, and did you hit C-j afterwards, or did you just hit the enter key?

In the Emacs manual, you will see references to key combinations such as "C-j" which means hold down either the left or right CONTROL keys, press the j key, and then release both keys.

You are not supposed to cut and paste all of that text shown in that web page. The "=>" part is meant to show what the value of that form is supposed to return, right there in the scratch buffer. The scratch buffers run what is called Lisp Interaction Mode which allows you to evaluate some Emacs Lisp expressions,and have the value inserted directly into the buffer. The Lisp Interaction mode is special in that it rebinds the C-j key sequence to say "get the last expression before the cursor (what the Emacs manual calls "the point") and then evaluate it, and insert the string-ified form of the resulting value right there into the buffer"

You can change the mode of (most) any buffer into Lisp Interaction mode by typing
Code:

M-x lisp-interaction RET
Where M-x means hold down the ALT key, then press x, then release both keys, then at the command prompt thus shown, type in lisp-interaction, and then hit the RETurn key.

bg

bzimmerly 12-18-2010 04:30 AM

Thank You Two!!!
 
Thanks ntubski and bgoodr! I commented out those lines and it worked perfectly. SWEET!

Here is the edited file:

(setq w (selected-window))
; => #<window 8 on windows.texi>
(window-edges) ; Edges in order:
; => (0 0 80 50) ; left--top--right--bottom

;; Returns window created
(setq w2 (split-window w 15))
; => #<window 28 on windows.texi>
(window-edges w2)
; => (0 15 80 50) ; Bottom window;
; top is line 15
(window-edges w)
; => (0 0 80 15) ; Top window

(setq w3 (split-window w 35 t))
; => #<window 32 on windows.texi>
(window-edges w3)
; => (35 0 80 15) ; Left edge at column 35
(window-edges w)
; => (0 0 35 15) ; Right edge at column 35
(window-edges w2)
; => (0 15 80 50) ; Bottom window unchanged

bzimmerly 12-18-2010 04:38 AM

Follow up...
 
It seems rather strange to me that they wouldn't have semicolons to comment out the text that began with the => symbols, which (if you didn't know LISP like me) had caused this problem.

Semicolons would clearly protect the pristine code and help a LISP newbie like me to know that it wasn't executable code.

Heck, they have other comments that used semicolons to protect it. I can't be the only one to have made this mistake. :(

I'll write the document authors and suggest an improvement.

Thanks again!

Sincerely,
- Bill


All times are GMT -5. The time now is 05:52 AM.