What is your recommended Emacs Lisp? - emacs

As for me, what I use is as follows recently
yasnippets -- http://code.google.com/p/yasnippet/
If there is a good code, Could you introduce it for me?

Obviously org-mode and remember-mode.
Highlight-parentheses

Related

How to jump to a Scheme definition in EMACS

EMACS has the Meta . key binding for SLIME, which only works in a limited fashion for Common Lisp.
Is there a more general way to go to a function definition that works with Scheme? Perhaps something that searches through the sources like Cscope?
For Racket use racket-mode written by Greg Hendershott.
https://github.com/greghendershott/racket-mode
The documentation on racket-visit-definition to which M-. is bound.
Docs on racket-visit-documentation
Try Geiser. It's the equivalent of SLIME for Scheme. M-. is there as well.
You can generate the tags files yourself using etags (similar to ctags for vim). These should work in vanilla emacs (without slime):
etags *.scm
etags won't walk directories recursively. As far as solutions for this, this looked promising: How to use shell magic to create a recursive etags using GNU etags?
etag docs: https://www.gnu.org/software/emacs/manual/html_node/eintr/etags.html

How can I write emacs lisp code for adding new highlighting pattern?

I found that font-lock-add-keywords is the key but I cannot find how to add a pattern. For example, in clojure;
(defn a-function-name [argument vector]
...)
a-function-name is highlighted becuase it's after defn and before [argument vector]. How can I write a rule for this?
(font-lock-add-keywords 'lisp-mode XXXXX)
I cannot write XXXXX part for myself.
=======================
Thank you to all of you :-) Yes, I can find clue in docs and clojure-mode.el as of you said.
Here is what I do and it works well (at least for me)
(font-lock-add-keywords
'lisp-mode
'(("(\\(#defn\\)\\>[ \r\t\n]*\\(\\sw+\\)+\\>?"
(2 'font-lock-function-name-face))))
Why I need this is that I define some macros and emacs does not highlight them properly.
Type C-h f font-lock-add-keywords. In the help for that function, there will be a link for font-lock-keywords, where the format for what you call XXXXXX is described.
If with that help you are still having trouble, post your attempt to achieve what you want so you can receive more specific help regarding your problem.
To add to what #juanleon said: See the Elisp manual, node Search-Based Fontification for information about font-lock-keywords. That will help you "write the XXXXX part for yourself."
Then, as #juanleon said, try something and ask for more help here if it doesn't work. Code tried gets help.

ispell in Emacs LaTeX mode

When I run Emacs command ispell-buffer on an Emacs buffer which is in the LaTeX mode, ispell checks spelling also inside math expressions.
I'd very much like to disable this. Is there an easy way to do it?
I've read about detex but detex does not seem to be integrated into Emacs.
It shouldn't do this, if you are using latexisms (eg. \[ ... \], equation environments, &c) to invoke math mode. Check the contents of ispell-tex-skip-alists; cf. section 6 of the ispell FAQ for what kind of thing should be there.
You can use $..$, $$..$$ to mark out maths using ispell-tex-skip-alists, but beware getting them out of kilter...
Postscript
Check also the value of the ispell-parser variable: this should be 'tex, otherwise ispell will not look for $...$ and $$...$$ regions.
Yes, you can: install aspell instead of ispell, and use flyspell with it.
This doesn't answer your question directly, but I have found Flyspell, an on-the-fly spell checker, incredibly useful when editing LaTeX documents. It still spellchecks inside equations, but it is much easier to ignore a few extra red underlines than ispell's interactive commands.
You may know this, but you can press A during spell checking to add a word to the buffer-local dictionary (that's capital A, lowercase a adds it to the global dictionary). It's not ideal, but this is how I usually suppress spell-checking of technical terms and variable names, etc., in my LaTeX documents.
This AUCTeX mailing list thread : "spell checker (ispell-buffer) complains about products in math modes" has some workarounds and the answer demonstrates how to use ispell-tex-skip-alists.
Another approach is to use ispell-skip-region-alist. The following example is to exclude org-mode src blocks:
(add-to-list 'ispell-skip-region-alist '("#\\+begin_src". "#\\+end_src"))

Can emacs longlines-mode or visual-line-mode be made to respect indentation and lists?

I use emacs to edit most of my answers for SO, and although I use longlines-mode (I have not upgraded to emacs 23 because of some critical bugs that don't look like being fixed any time soon), I can't find a way to get longlines-mode to respect the indentation used for Markdown. I would really like to fix this, but I want it for an ordinary buffer, not for org-mode (as already answered).
Does anybody have suggestions on how I can get longlines-mode to indent wrapped lines? I am definitely willing to try hacking the Emacs Lisp, although my Emacs Lisp is pretty rusty...
I just looked through the source code of longlines.el. There doesn't seem to be any hook there to have the wrapped lines indented. If you want to do this, you'll need to write a bit of elisp (and, more importantly, understand all of the functions for doing text-properties.)

Lisp/Scheme interpreter without Emacs?

I've been wanting to teach myself Lisp for a while. However, all the interpreters of which I've heard involve some flavor of emacs.
Are there any command line interpreters, such that I could type this into the command line:
lispinterpret sourcefile.lisp
just like I can run perl or python.
While I'd also like to become more familiar with Emacs (if only not to be frustrated when I work with somebody who uses Emacs), I'd rather decouple learning Emacs from learning Lisp.
Edit: I actually want to follow SICP which uses Scheme, so an answer about Scheme would be more useful. I'm just not that familiar with the differences.
You could also try DrScheme, which whilst not exactly a standalone interpreter, isn't emacs :)
It's basically a simple IDE that has an area to type in code that can be executed as a file, and then another area that is the running interpreter that you can interact with.
(Also, find the UC Berkeley CS61A podcasts and listen to them, as well as reading SICP)
It looks like Steel Bank Common Lisp (SBCL) also caters to what you want:
http://www.sbcl.org/manual/#Shebang-Scripts
SBCL is both top rate and open source.
Checkout CLISP wiki-link that ie. was used by Paul Graham
Direct link
I often write lisp shell scripts which start with this line:
#!/usr/bin/clisp
Then you don't even need to type "lispinterpret" on the command-line. Just mark the script executable and run it directly.
Most scheme interpreters that I am familiar with can be run from the command line. (Much of the list below is extracted from the comparative table at Alexey Radul's Scheme Implementation Choices page. There is a more extensive list at schemewiki but that page does not immediately provide command-line invocation syntax.)
Here's how you run a number of implementations at the command line:
Chez Scheme: scheme, petite
MIT Scheme: mit-scheme
Scheme 48: scheme48
RScheme: rs
Racket: racket (But I recommend trying the DrRacket IDE, especially for beginners.)
Guile: guile
Bigloo: bigloo
Chicken: csi
Gambit: gsi
Gauche: gosh
IronScheme: IronScheme.Console
Kawa: kawa, java kawa.repl
Larceny: larceny
SCM: scm
If you are looking for Scheme to work with the SICP, take a look at MIT/GNU Scheme
http://groups.csail.mit.edu/mac/projects/scheme/
http://www.gnu.org/software/mit-scheme/index.html
The most widely used IDE for Common Lisp, particularly in the free software subset of the community, is in fact SLIME, which runs on Emacs. You can use whatever CL compiler you prefer and invoke Lisp source files the way you describe, but if you do that, you won't be taking advantage of many of Lisps dynamic features that are so incredibly useful while developing your application.
I suggest you take a look at this SLIME demonstration video to see what I mean, even though it might be a bit outdated at this point.
If the problem is that you (think you) don't like Emacs, I seriously suggest you try to learn it. Seriously. No, really, I mean that. However, there are alternatives, such as the IDEs provided by commercial Lisp implementations such as Allegro and Lispworks (free trials available), or an Eclipse plug-in called Cusp.
Did you try Allegro CL from http://www.franz.com/?
#Nathan: I've upmodded the Common Lisp links, because you asked about Lisp (especially with reference to Emacs Lisp). However, Common Lisp is very different from Scheme. A program written for one is unlikely to run on the other.
As you mentioned, SICP is for learning Scheme, not Lisp (or at least, not Common Lisp and not Emacs Lisp). There are some overlap in principles, however you can't simply cut and paste code from SICP and expect it to run on any Common Lisp or Emacs Lisp system. :-)
No "interpreter" requires emacs.
Also, emacs can run elisp in a headless manner.
It seems like scheme shell is suitable for your purpose.
Take a look at http://www.scsh.net/index.html
Another good dialect of lisp is cmucl. They used to love to brag about being the "fastest" lisp.