Why am I getting an elisp error? - emacs

I just installed yasnippets and addeded these snippets for latex https://github.com/madsdk/yasnippets-latex/
When I try to expand a snippet like "eq" I get the following:
\begin{equation}
\label{[yas] elisp error!}
\end{equation}
Why is this happening, and how do I fix it?

The debug-on-error didn't do anything, I guess because of the good-grace thing. But turning on reftex-mode fixed the problem.

Related

How to add \Sexpr{} to Emacs/AUCTeX verbatim environment

I have the very same problem detailed here caused by the '$'-included in the \Sexpr command-breaking the syntax highlighting of Emacs. Unfortunately no definitive solution has been proposed yet.
Now I read a solution for a similar problem here that I am trying to adapt to my situation. The idea is to set \Sexpr as verbatim environment in Emacs' preferences.
I tried
(setq LaTeX-verbatim-environments-local '("Sexpr"))
but with no result.
Using
(add-to-list 'LaTeX-verbatim-macros-with-braces "Sexpr")
and restarting LaTeX-mode worked for me.

org-mode broken dynamic clock: Symbol's function definition is void: org-defvaralias

For months I've been enjoying use of the org dynamic clock block (C-c C-x C-r) to help with my hour clocking. Suddenly I find it's not working, though. The only things I've changed is downloading the list-packages org-contrib and org-mode.
M-x org-version
Org-mode version 7.8.11
Attempt to update/add dynamic block (C-c C-x C-r)
Symbol's function definition is void: org-defvaralias
I tried to do manual execution of defuns in some of the org .el files, but that just made things worse. Any suggestions on the cleanest way to fix this?
I actually can't even clock-in anymore, with the same error.
I have verified that this is a result of the org-contrib install from ELPA, which seems to break it. This is sad, since I was putting good use to other org-contrib files.
I finally got around to fixing this. The key resource was http://orgmode.org/manual/Installation.html, and the solution boils down to two things I was doing wrong when I tried to install through the list-packages:
Remember to start have emacs running without having opened ANY org files or org-config settings. Best way to do this is M-xkill-emacs and start again with emacs -q.
Add to the top of your .emacs file:
;; Configure before loading org mode (package-initialize)
(package-initialize)
I've written a little more about it here.
I don't know if that helps, but you could try:
M-x load-library RET org-compat RET.
Even if it works, this is not the solution, simply an ugly workaround.
Try asking your question on the orgmode mailing list, it gets more audience there.

Emacs indent-line-function

i try to indent sql file lines in emacs, I think the c-indent-line is pretty good for me, so i write this code to my init file:
(defun my-sql-mode ()
(setq indent-line-function 'c-indent-line)
)
(add-hook 'sql-mode-hook 'my-sql-mode)
But when i use tab to indent the line, it always give me the tips of 'Wrong type argument: stringp, nil'.
Can someone help me?
Indentation in Emacs is generally intelligent, but it's not magic.
c-indent-line is a function designed for use with C and C++ code. It shouldn't be greatly surprising that it might not work in other contexts, and I'm not sure what you were expecting it to do when faced with SQL code?
I'm afraid the answer is simply: Don't do that.
If you tell us what you wanted it to do, however, someone might be able to help.

What does ad-activate do?

In an answer, I noticed:
;; Align with spaces only
(defadvice align-regexp (around align-regexp-with-spaces)
"Never use tabs for alignment."
(let ((indent-tabs-mode nil))
ad-do-it))
(ad-activate 'align-regexp)
This sounds promising, but... what does it do?!
I tried eval-region on the block of code. But for me, all it does is adding the following to the align-regexp docs:
This function is advised.
Around-advice `align-regexp-with-spaces':
Never use tabs for alignment.
I don't seem to be able to actually use align-regexp-with-spaces, if that's what should be the effect... What am I missing?
I used GNU Emacs version 24.0.96.1 (i386-mingw-nt6.1.7601).
While asking this question, I realized that I just didn't get the idea of advising functions.
It became clear to me that:
align-regexp-with-spaces isn't a function nor a variable but only a name (to enable/disable single pieces of advice)
ever since (ad-activate 'align-regexp), align-regexp just does what I 'advised' it to: not to use tabs
So: ad-activate activates the advice, effectively changing the original function's behavior. Great!
I don't get why this is 'better' than defining a function around align-regexp though. But then again I don't know much about Emacs Lisp.
I'm afraid the extra lines of documentation only added to the confusion...

Emacs Lisp syntax highlighting

I want to write a syntax highlighting extension for Emacs, but I Googling of variations on "emacs syntax highlight tutorial" have all failed. How do I go about learning how to write an Emacs highlighter? What good resources are there for learning how to do such things?
You're looking in the wrong place. Look at "font-lock-mode".
There's a related question, on how to define a major mode with syntax highlighting using 'define-generic-mode. The question focuses on figuring out how to get the syntax highlighting working.
unfortunately you were searching for the wrong terms, "syntax highlighting" is not emacs vocabulary :). You should have searched for something like "write emacs mode".
There was already a question for this: "How to write an emacs mode for a new language" with some good pointers.
If you are interested in writing your own highlighting, another question covered this and may be of value to you. It included this code snippet:
(defun django-highlight-comments ()
(interactive "p")
(highlight-regexp "{%.*?%}" 'hi-orange))
(add-hook 'html-mode-hook 'django-highlight-comments)
Code courtesy of Ashutosh Mehra's answer.
http://a-kat.com/Emacs_Major_Modes.html