Emacs fixme mode on javascript - emacs

I just got fixme-mode.el, and loaded it. It works just fine on C, Lisp and other languages. But it doesn't work on Javascript.
(defcustom fixme-modes '(erlang-mode java-mode c-mode emacs-lisp-mode jde-mode
scheme-mode python-mode ruby-mode cperl-mode
slime-mode common-lisp-mode c++-mode d-mode
js2-mode haskell-mode tuareg-mode lua-mode
pascal-mode fortran-mode prolog-mode asm-mode
csharp-mode sml-mode javascript-mode html-mode)
"The modes which fixme should apply to"
:group 'fixme-mode)
I even added javascript-mode and html-mode to the list, but it still doesn't work.
Is there a way I can make it work for all modes? Is there like an "emacs-mode" that includes all others? If not, why isn't it working on .js files?
Thank you!

if you are emacs emacs inbuilt javascript mode (I guess you are using that) that is js-mode not javascript-mode
add this .emacs file(~/.emacs.d/init.el)
(add-to-list 'fixme-modes 'js-mode)
Generally you don't edit defcustom directly in the source code. .emacs is the one for your customizations
UPDATE:
To make fixme-mode to be available for all buffers we should define a global-minor-mode
(defun turn-on-fixme-mode ()
(fixme-mode 1))
(define-global-minor-mode global-fixme-mode
fixme-mode turn-on-fixme-mode
:group 'fixme-mode)
now call global-fixme-mode

Related

Emacs: Gloabally disable flycheck/prettier temporarily

I often use rgrep to find files I need to change and then a macro to go through these files, do the change and save it. It's a very neat flow with one downside: I have prettier check each file on save and flycheck (using eslint) also goes absolutely crazy and maxes out my CPU.
So I wondered, if there is any good way to globally (as my macro visits a lot of files) disable temporarily (as I want these modes after the macro finished) certain modes, most importantly flycheck?
I didn't find anything related, any ideas on how this could be done?
EDIT:
This is how I load flycheck e.g. in rjsx-mode:
;; disable jshint since we prefer eslint checking
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
;; use eslint with web-mode for jsx files
(defun my/use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
(flycheck-add-mode 'javascript-eslint 'rjsx-mode)
(Full emacs config here: https://github.com/phuhl/sheeshmacs)
Thx
Try changing your macro to open files with find-file-literally. This will always open files in Fundamental mode, preventing flycheck from running (well, assuming you have no flycheck hooks for Fundamental mode.)
See C-h f find-file-literally or Visiting in the Emacs manual.

What is the difference of tex-mode and latex-mode and LaTeX-mode in emacs

I am configuring AUCTeX in emacs.
Most of the configurations are put in a LaTeX-mode-hook. When I open a main.tex file, I notice that the major mode is latex-mode and my hooked configurations are not activated. I have to M-x Tex-latex-mode to activate them. But the major-mode is still latex-mode.
(add-hook 'LaTeX-mode-hook
(lambda ()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; auctex
(setq TeX-auto-save t)
(setq TeX-parse-self t)
))
So I would like to know what is the difference of these modes and how can I turn on AUCTeX automatically when I open a *.tex file.
The modes provided by AUCTeX are listed at https://www.gnu.org/software/auctex/manual/auctex.html#Modes-and-Hooks and they are
plain-TeX-mode
LaTeX-mode
ams-TeX-mode
ConTeXt-mode
Texinfo-mode
docTeX-mode
Instead,
tex-mode
plain-tex-mode
latex-mode
slitex-mode
doctex-mode
(note the different capitalization) are the major modes provided by the TeX mode package shipped with Emacs.
If you want to open all *.tex files with AUCTeX LaTeX mode add this to your .emacs:
(add-to-list 'auto-mode-alist '("\\.tex$" . LaTeX-mode))
Actually, this shouldn't be necessary, because AUCTeX defines the tex-mode.el mode names as alias of its own modes.
TLDR: Use latex-mode or LaTeX-mode (they mean the same thing), no need to change auto-mode-alist, and use LaTeX-mode-hook for hooking into AucTeX.
Setting up AucTeX can be quite confusing, because it uses advice to override Emacs' built-in support for TeX and friends.
So, after installing AucTeX from ELPA, you should see the following in C-h f latex-mode:
This function has :override advice: ‘TeX-latex-mode’.
Same for all the other tex modes, though the list of modes that AucTeX overrides depends on the value of the TeX-modes variable.
The function LaTeX-mode is not defined in AucTeX (any more?): it's defined in core Emacs, with a cryptic comment about compatibility:
;; The following three autoloaded aliases appear to conflict with
;; AUCTeX. However, even though AUCTeX uses the mixed case variants
;; for all mode relevant variables and hooks, the invocation function
;; and setting of `major-mode' themselves need to be lowercase for
;; AUCTeX to provide a fully functional user-level replacement. So
;; these aliases should remain as they are, in particular since AUCTeX
;; users are likely to use them.
;; Note from Stef: I don't understand the above explanation, the only
;; justification I can find to keep those confusing aliases is for those
;; users who may have files annotated with -*- LaTeX -*- (e.g. because they
;; received them from someone using AUCTeX).
;;;###autoload
(defalias 'TeX-mode #'tex-mode)
;;;###autoload
(defalias 'plain-TeX-mode #'plain-tex-mode)
;;;###autoload
(defalias 'LaTeX-mode #'latex-mode)
What this all means is that, at least in 2021, you do not need to change auto-mode-alist to use AucTeX; just installing it is enough for it to override Emacs' builtin functionality.
Unfortunately, there's one last source of confusion. Even though LaTeX-mode is now mostly just a useless alias for latex-mode, it turns out that code in AucTeX that overrides latex-mode does not call latex-mode-hook (it calls LaTeX-mode-hook, which is different. So the LaTeX- variables, which are the AucTeX ones (as opposed to the lowercase ones that are builtin with Emacs), are still useful.

Auto Completion with auto-complete OR predictive based on mode

I'm using emacs-snapshot (24.2.50) on Xubuntu 12.10. For completion I am currently using auto-complete (v1.4).
I have a pretty nice setup of auto-complete with various sources, including the semantic source for code completion of my c++ programming. However, I'd like to switch to predictive-mode for completion of LaTeX documents (I'm using AUCTeX for all LaTeX related stuff).
My current auto-complete config (for LaTeX; I omitted all non-LaTeX config) looks like this:
(require 'auto-complete-latex)
(require 'ac-math)
(add-to-list 'ac-modes 'latex-mode) ; make auto-complete aware of {{{latex-mode}}}
(defun ac-latex-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-latex ac-source-latex-commands)
ac-sources))
)
(add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup)
After adding predictive to the load-path and doing the auto-load stuff as described here I tried to disable auto-complete for LaTeX-mode and enable predictive-mode in turn by exchanging the above code by this:
(defun ele/latex-mode-completion-setup ()
(auto-complete-mode -1)
(predictive-mode 1)
)
(add-hook 'LaTeX-mode-hook 'ele/latex-mode-completion-setup)
Unfortunately this doesn't work as expected: auto-complete is actually disabled but predictive-mode is not enabled and instead of using AUCTeX the build-in tex-mode is used.
I have uploaded all LaTeX related config here. Note that this is loaded after the above completion setup, but this is the case for the old auto-complete based setup as well. Also note that exchanging that order does not make a difference as far as I can tell. Furthermore I found that simply commenting the auto-complete config (first snippet I posted) results in the same behaviour: tex-mode is used instead of AUCTeX.
I don't want to switch to predictive-mode for all modes but I really like many features it provides when doing LaTeX editing.
Any suggestions?
(remove-hook
might clear the hook, not to run unwanted stuff - just a suggestion indeed

Auto-complete mode doesn't turn on automatically in ObjC buffers

I load auto-complete mode like this:
(let ((ac-path "path/to/auto-complete"))
(add-to-list 'load-path ac-path)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (concat ac-path "ac-dict"))
(ac-config-default))
It works fine with C major mode, but doesn't turn on automatically when I open ObjC files. I can still turn it on manually and it will work fine along with the ObjC major mode.
Here's a snippet from the docs regarding ObjC major mode:
The hook `c-mode-common-hook' is run with no args
at mode initialization, then `objc-mode-hook'.
If I understand correctly, auto-complete adds a hook to the c-mode-common-hook, but objc-mode-hook somehow overrides it. Is there a way to fix this?
Thanks.
While looking through the source code of auto-complete.el, I've stumbled upon this definition
(defcustom ac-modes
'(emacs-lisp-mode
lisp-interaction-mode
c-mode cc-mode c++-mode
java-mode clojure-mode scala-mode
scheme-mode
ocaml-mode tuareg-mode
perl-mode cperl-mode python-mode ruby-mode
ecmascript-mode javascript-mode js-mode js2-mode php-mode css-mode
makefile-mode sh-mode fortran-mode f90-mode ada-mode
xml-mode sgml-mode)
"Major modes `auto-complete-mode' can run on."
:type '(repeat symbol)
:group 'auto-complete)
It turns out that auto-complete doesn't have a true global mode. It is enabled only with those major modes that are included in the ac-modes variable.
So, adding the following line to the .emacs file has solved the issue for me.
; add this line after the auto-complete mode has been loaded
(add-to-list 'ac-modes 'objc-mode)
Use the following:
(defun my-objc-mode-hook ()
(auto-complete-mode 1))
(add-hook 'objc-mode-hook 'my-objc-mode-hook)
Note 1: The function auto-complete-mode is a toggle function, when called with no arguments.
Note 2: It's possible to add an anonymous function using lambda, but this have several drawbacks. The most important ones are: modifying the function and reevaluating the expression will add the modified function in addition to the earlier version and C-h v xxx will print the full unformatted lambda function, which typically is hopeless to read and understand.
(add-hook 'objc-mode-hook 'auto-complete-mode)
That should do it if you're using auto-complete-mode. You can add more complex things to mode hooks by doing:
(add-hook 'objc-mode-hook '(lambda ()
(something-with arguments)))
Note that both arguments to add-hook are quoted, this is necessary and if you add unquoted functions they will probably not work.

Emacs color syntax configuration

Does anyone know if I can find an emacs color syntax configuration which resembles eclipse's syntax coloring? Thank you for any suggestion.
I'm not sure what Eclipse looks like, but you might want to check out Color Theme There are lots of color themes included with it and you can easily create you own if you don't like any you see.
I think you want font-lock. The emacs name for syntax coloring. I get it with the mode (Java mode, C# mode, cc-mode, etc).
I have in my .emacs:
;; for fontification in emacs progmodes:
(load "font-lock")
(setq font-lock-maximum-decoration t)
;; turn on font-lock globally
(global-font-lock-mode 1 'ON)
And then it just works, for all the various prog modes.
Emacs with C# http://www.freeimagehosting.net/uploads/6be39f23a3.jpg
Try this... http://jasonm23.github.com/emacs-theme-editor/
It will customize most of the standard font-lock parameters (keywords, functions, constants, vars, etc....)
You can paste in an existing theme and edit it, if you have something almost right.
There's a few samples on http://jasonm23.github.com
You might also like the code theme generator at http://inspiration.sweyla.com/code/
I use the same .xemacs/init.el file for both Emacs and Xemacs.
In order for it to work, I use the following:
; turn on faces
(font-lock-mode 1)
;; Turn on font-lock mode for Emacs
(cond ((not running-xemacs)
(global-font-lock-mode t)
))
Also you might need to add modes for various files. For example:
(setq auto-mode-alist (mapcar 'purecopy
'(("\\.c$" . c-mode)
("\\.cc$" . c-mode)
("\\.cxx$" . c++-mode)
("\\.htm$" . html-mode)
("\\.java$" . java-mode))))
Note there is also a Go mode for emacs which supports color highlighting. URL for Go-mode for Emacs