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.
Related
Haven't found a way to indent/autoformat HOCON config files. What is you way here?
I'm fairly certain there isn't an Emacs major mode for HOCON. But it looks like it's similar to JavaScript, so you can make .hocon load as JavaScript by adding this to your .emacs:
(add-to-list 'auto-mode-alist '("\\.hocon\\'" . javascript-mode))
I think it's quite similar to the syntax of HCL. You might be interested in using emacs-hcl-mode for editing HOCON files.
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.
the guys of the plain tex-mode have added a very nice feature with emacs 24.1, a minor mode called latex-electric-env-pair-mode which keeps existing \begin{...} [...] \end{...} pairs matched. I.e. when changing the environment name in the \begin{...} tag, its corresponding \end{...} is changed automatically (very nice when changing from starred to non-starred version of an environment and vice-versa).
However, when comparing with AUCTeX, the tex-mode still sucks... but I really like the new minor mode. I have tried to make a stand-alone minor mode by copying everything that looked like it was used from tex-mode.el to a new file and changed all the descriptors (so they won't conflict with AUCTeX or any remainders for tex-mode). Unfortunately this won't work, the minor mode can be turned on but it is broke: nothing is happening.
I'm not a (e)lisp programmer, that is to say I don't really understand the code. But maybe someone likes the feature of this minor mode and can port it to a stand-alone version?
Also there might be some package out there which provides similar/equal functionality?
I'd appreciate any help!
You probably missed tex-env-mark (which sets marks that are used later by latex-electric-env-pair-mode to find environment starters/enders) or latex-syntax-propertize-rules (which runs tex-env-marks on relevant parts of the buffer) or the setting of syntax-propertize-function (which uses latex-syntax-propertize-rules so that these rules are actually used).
BTW, rather than copying those things, I recommend you try something like the untested code below:
(defconst my-latex-syntax-propertize-function
(with-temp-buffer (latex-mode) syntax-propertize-function))
(add-hook 'LaTeX-mode-hook
(lambda ()
(set (make-local-variable 'syntax-propertize-function)
my-latex-syntax-propertize-function)
(latex-electric-env-pair-mode 1)))
Emacs 23.2 in emacs-starter-kit v1 has C-x C-i (or ido-imenu) (similar to Sublime Text's Cmd+R). Emacs24 in emacs-starter-kit v2 lacks this function. I found this github issue and a fix, which try to recreate the functionality. While this ido-imenu works in elisp-mode, it stopped working in ruby-mode. I get:
imenu--make-index-alist: No items suitable for an index found in this buffer
Has anyone figured out how to get this to work?
Why was this taken out of Emacs24?
Is there a new replacement for this function?
Since the function is part of ESK (as opposed to something budled with Emacs) you'd probably do best to report the bug upstream. On a related note ESK main competitor Emacs Prelude offers the same functionality (bound to C-c i by default) and it seems to be working fine with ruby-mode in Emacs 24. Here you can find more on ido-imenu.
So I finally figured it out, after reading the Defining an Imenu Menu for a Mode section on emacs-wiki again.
Short answer: you need to add this bit to your customization. Feel free to add more types to the list (I am happy with just methods).
(add-hook 'ruby-mode-hook
(lambda ()
(set (make-local-variable imenu-generic-expression)
'(("Methods" "^\\( *\\(def\\) +.+\\)" 1)
))))
Longer answer: I first tried to define a ruby-imenu-generic-expression function and set that to imenu-generic-expression by using the ruby-mode-hook:
(defvar ruby-imenu-generic-expression
'(("Methods" "^\\( *\\(def\\) +.+\\)" 1))
"The imenu regex to parse an outline of the ruby file")
(defun ruby-set-imenu-generic-expression ()
(make-local-variable 'imenu-generic-expression)
(make-local-variable 'imenu-create-index-function)
(setq imenu-create-index-function 'imenu-default-create-index-function)
(setq imenu-generic-expression ruby-imenu-generic-expression))
(add-hook 'ruby-mode-hook 'ruby-set-imenu-generic-expression)
This however did not work (I would get the same error as before). More reading of the Defining an Imenu Menu for a Mode section showed me the way. Now, I'm not an elisp expert, so here's my hypothesis: basically, the above method works for modes where the
major mode supports a buffer local copy of the “real” variable, ‘imenu-generic-expression’. If your mode doesn’t do it, you will have to rely on a hook.
The example for foo-mode made it clear how to do it for ruby-mode. So it appears that ruby-mode does not have a buffer-local copy of the real imenu-generic-expression variable. I still can't explain why it worked in Emacs 23.2 (with ESK v1) but does not on Emacs24, but hey at least I found a working solution.
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