When I open an HTML file with emacs (and nXhtml,) I get the following error from flymake:
Error (flymake): Flymake: Failed to launch syntax check process 'xml'
with args (val
/home/ABC/Downloads/capitals_flymake.html):
Searching for program: no such file or directory, xml. Flymake will be
switched OFF
I assume this means that I need to have a program installed that can be run at the command line with xml. However, I have not been able to find out what this program is in the documentation.
I am also currently using the following gist (with a modification suggested by one of the commenters to change equal to >=) to disable the Mumamo buffer filenames warning in my .emacs:
;; Workaround the annoying warnings:
;; Warning (mumamo-per-buffer-local-vars):
;; Already 'permanent-local t: buffer-file-name
(when
(and
(>= emacs-major-version 24)
(>= emacs-minor-version 2))
(eval-after-load "mumamo"
'(setq mumamo-per-buffer-local-vars
(delq 'buffer-file-name mumamo-per-buffer-local-vars))))
But, I am not sure if that is relevant.
How can I get flymake to work with nXhtml? I am currently on GNU Emacs 24.3.1.
I have this in my .emacs for live validating of XML and HTML, see if this would help.
(defun flymake-xml-init ()
(list "xmllint"
(list "--valid"
(flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))))
(defun flymake-html-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "tidy" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.html$" flymake-html-init))
Also, re xml executable: it might be this one http://packages.ubuntu.com/quantal/amd64/xml2/filelist from how it looks... also you can try apt-file /usr/bin/xml (I'm not sure if apt-file is installed by default, if not, then apt-get install apt-file). Also, maybe this would help: http://www.emacswiki.org/emacs/FlyMake . I couldn't find any setting particular to nXhtml that does something to flymake.
The default program that flymake is told to use (xml) isn't installed on your computer, or its location isn't in your path. You need to tell flymake to use a different syntax checker just like #wvxvw said (see their answer for the code).
However, when you change the syntax checker, you may also need to tell flymake how that new checker will output error messages or else flymake won't know how to read the checker's output.
If your new checker program has an exit code other than 0 (which normally indicates an error) AND flymake didn't see anything that it recognized as error text, then flymake will throw a CFGERR and turn off.
From the flymake manual:
The following errors cause a warning message and switch flymake mode OFF for the buffer.
CFGERR : Syntax check process returned nonzero exit code, but no errors/warnings were reported. This indicates a possible configuration error (for example, no suitable error message patterns for the syntax check tool)
So what you need to do is tell flymake how to interpret the errors from your updated parser. You do this by adding a regex expression to a list that flymake will check against the output of your parser. Add something like this to your .emacs file:
(add-to-list
`flymake-err-line-patterns
'("at line \\([0-9]+\\) of \"\\([^ \n]+\\)\"$" 2 1 nil))
This will then tell flymake that if your parser generates output that matches the regex ("at line \\([0-9]+\\) of \"\\([^ \n]+\\)\"$") to identify it as an error message. The 2 1 nil tell flymake which group in the regex represents the file, line number, and column number, respectively. If the error message doesn't provide that information, then set that parameter to nil. In this example, the error message only identifies the file (second group) and line number (first group), so the column is set to nil.
Related
Whenever I open emacs on a linux server I'm using I get the following message which takes up half my screen:
Warning (initialization): An error occurred while loading `/home/[my username]/.emacs':
File error: Cannot open load file, sm
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
What's happening here? I don't have any issues editing, except for this warning message in the way. How can I address this?
EDIT:
My ~/.emacs file contains the following:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Supermongo (SM) mode stuff
;;
(require 'sm)
(setq auto-mode-alist
(append
'( ("\\.sm\\'" . sm-mode) )
auto-mode-alist)
)
Your load-path variable is probably set missing something. You need to add a path so that the sm.el (or sm.elc) file can be found by emacs. Something like this at the beginning of your .emacs file:
(add-to-list 'load-path "/path/to/directory/containing/sm.el")
I'm using ps-print-buffer-with-faces to print out code with colored syntax highlighting (in emacs).
This works fine if I call ps-print-buffer-with-faces interactively (using M-x for example). I've also got it working from a bash script so that I can print in color from the command line. No problem.
However, I want to be able to perform this from cron, or possibly from a Makefile (i.e. without X11)
I've tried using the emacs -nw option and it complains that stdin is not from a tty and will not continue.
When I use the emacs --batch option, it appears that it is working, but the resulting postscript file has no colors at all.
Does anyone know how I can get ps-print-buffer-with-faces to obtain colors without X11?
This really bring back some memories -- I wrote a package like that back in the 1990:s, unfortunately, I have lost the source code (this was long before I started using a version control system).
The key to using font-lock in batch mode is to fool it into believing that it's in interactive mode, by setting noninteractive to nil.
I just threw together the following, is saves a postscript file named ORIGINAL_BASENAME.ps. You can easily modify this to print to the printer directly, by not passing the file name parameter.
#!/usr/bin/emacs --script
(defun ps-batch-print (files)
(dolist (source files)
(unless (file-exists-p source)
(user-error "File not found: %s" source))
(find-file source)
(let ((noninteractive nil))
(font-lock-mode 1))
(ps-print-buffer-with-faces (concat (file-name-nondirectory
(file-name-sans-extension source))
".ps"))))
(ps-batch-print command-line-args-left)
As always, Emacs packages print tons of messages irrelevant when in batch mode. You can get rid of them by redirecting stderr using 2> /dev/null, if you are using a UNIX-like system.
I would like to configure emacs so that the Icy mode is active by default. As suggested in "icicles-doc1.el", I added the following code at the end of my .emacs file:
(require 'icicles)
(icicle-mode 1)
When I run emacs, I get a *Warning* buffer:
Warning (initialization): An error occurred while loading `c:/Users/USER/AppData/Roaming/.emacs':
File error: Cannot open load file, icicles
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
When I do the debug option, a *Backtrace* buffer says something like:
Debugger entered--Lisp error: (file-error "Cannot open load file" "icicles")
require(icicles)
eval-buffer(# nil "c:/Users/USER/AppData/Roaming/.emacs" nil t) ;
Reading at buffer position 5062
load-with-code-conversion("c:/Users/USER/AppData/Roaming/.emacs"
"c:/Users/USER/AppData/Roaming/.emacs" t t)
load("~/.emacs" t t)
#[0 "\205\262
With or without those two lines in my .emacs that are causing the problem, icicle-mode seems to work fine when I do a M-x icicle-mode.
(file-error "Cannot open load file" "icicles") means that Emacs didn't know where to find library icicles.el[c]. You need to put the location of the Icicles files in variable load-path.
E.g, if your Icicles files are in directory /my/icicles/ then you need to do this (e.g., in your init file, ~/.emacs):
(add-to-list 'load-path "/my/icicles/")
Do that before you do (require 'icicles). That way, Emacs will know where to load Icicles from.
Given that the (require 'icicles) code is failing, but the M-x icy-mode is working, then it seems that someone has already set up your Emacs installation to include icicles via an autoload command, but didn't update the load-path to include the directory where icicles.el resides.
Replace those two lines with:
(icy-mode 1)
(which is the equivalent of M-x icy-mode when icicles has yet to be enabled)
If you want to use a different version of icicles, then you need to add the proper directory to the load path.
I'm trying to feed flymake output from Haxe compiler, but I don't know how to tell it where the make file lives (ideally, I'd use nxml file instead). So far I have this in the Makefile:
BIN = ./bin
MAIN = com.wunderwafer.Main
SWF = wunderwafer.swf
SWFSETTINGS = -debug -swf-version 10 -swf-header 800:600:31
HFLAGS = -main $(MAIN) $(SWFSETTINGS) -cp ./src -swf $(BIN)/$(SWF)
HC = haxe
default: compile
compile: $(HC) $(HFLAGS)
clean:
$(RM) -r $(BIN)/*
.PHONY: check-syntax
check-syntax:
$(HC) $(HFLAGS)
If I run it later like so:
$ make -k check-syntax
It produces the expected output. However flymake isn't able to find the Makefile (or so it seems) because the files I'm trying to check are deeper inside the src directory.
What is the way to configure flymake so it knows where the makefile is? (or, even better, just execute a shell command, because the common way to compile Haxe code is by using *.nxml settings file.
EDIT:
It looks like I'm getting closer, lots of thanks, but flymake is doing something strange, and I can't understand what exactly it does, so, here's the log:
received 65 byte(s) of output from process 967
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
parsed 'Error : Invalid class name /home/wvxvw/projects/wafer/build.nxml', no line-err-info
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
process 967 exited with code 1
cleaning up using haxe-flymake-cleanup
deleted file /tmp/flymake-Battlefield-855Cad.hx
Battlefield.hx: 0 error(s), 0 warning(s) in 0.15 second(s)
switched OFF Flymake mode for buffer Battlefield.hx due to fatal status CFGERR, warning Configuration error has occurred while running (haxe /home/wvxvw/projects/wafer/build.nxml)
The command I'm trying to make it run looks like this:
(defun haxe-flymake-get-cmdline (source base-dir)
"Gets the cmd line for running a flymake session in a Haxe buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments. The resulting command is like:
$ haxe ${project-root}/build.nxml
"
(message "base-dir %s" (file-name-as-directory base-dir))
(list *haxe-compiler*
(list
(concat (file-name-as-directory base-dir)
*build-nxml*))))
The message printed looks like this:
base-dir /home/wvxvw/projects/wafer/
So, as far as I could understand, the resulting command should be:
haxe /home/wvxvw/projects/wafer/build.nxml
But it looks like flymake either adds something in front of the argument or afterwards, which makes Haxe compiler generate the error "Error : Invalid class name" - this error would be given if there was one extra argument, which the compiler would have understood as an extra class to compile. But the log doesn't show what is being sent...
EDIT 2:
I've added:
#!/usr/bin/env bash
echo "$#" > /home/wvxvw/projects/wafer/log
And made flymake invoke this script instead of the compiler, and it passes only one argument, just as I would expect it... sigh
It's a good question. I don't know a simple way of adding in a new "flavor" of make tool into flymake. I know of a way, it's just not simple. This is what I did for php codesniffer - it will be similar for any arbitrary make tool.
First, define an install fn.
(defun fly/phpcs-install ()
"install flymake stuff for PHP CodeSniffer files."
(add-to-list
'flymake-err-line-patterns
(list fly/phpcs-error-pattern 1 2 3 4))
(let* ((key "\\.php\\'")
(phpentry (assoc key flymake-allowed-file-name-masks)))
(if phpentry
(setcdr phpentry '(fly/phpcs-init fly/phpcs-cleanup))
(add-to-list
'flymake-allowed-file-name-masks
(list key 'fly/phpcs-init 'fly/phpcs-cleanup)))))
This installs a new entry into the flymake alist, keyed on .php as a file extension. The entry in flymake's list basically relates the file extension to a pair of functions, one for init and one for cleanup.
The init fn simply returns the command to run to check syntax. This can be a shell command, with the appropriate arguments. For codesniffer this fn looks like this:
(defun fly/phpcs-init ()
"initialize flymake for PHP using the PHP CodeSniffer tool."
(let ((create-temp-f 'fly/phpcs-create-temp-intemp)
(use-relative-base-dir t)
(use-relative-source t)
(get-cmdline-f 'fly/phpcs-get-cmdline)
args
temp-source-file-name)
(setq temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)
args (flymake-get-syntax-check-program-args
temp-source-file-name "."
use-relative-base-dir use-relative-source
get-cmdline-f))
args))
Yikes! Down the rabbit hole we go. The get-cmdline fn looks like this:
(defun fly/phpcs-get-cmdline (source base-dir)
"Gets the cmd line for running a flymake session in a PHP buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments. The resulting command is like:
php.exe -d auto_append_file="" -d auto_prepend_file="" phpcs\scripts\phpcs --report=emacs file.php
"
(list fly/phpcs-phpexe
(list
"-d" "auto_append_file=''"
"-d" "auto_prepend_file=''"
(concat (file-name-as-directory fly/phpcs-phpcs-dir)
"scripts\\phpcs")
(concat "--standard=" fly/phpcs-standard)
"--report=emacs"
"-s" ;; show the fullname of the rule being violated
(expand-file-name source))))
You can see the full elisp at http://www.emacswiki.org/emacs/flyphpcs.el
There's probably a simpler way. I just don't know it.
I'm using python-mode 6.0.1 on OS X, emacs 23.3 (http://emacsformacosx.com/ version).
I'm trying to get C-c C-c to default to python 3.
I have the following in my .emacs:
(setq py-python-command "/usr/local/bin/python3")
And when I run C-h b py-python-command, it tells me the value is that (correctly).
However, running C-c C-c still opens 2.7.2.
I also tried adding:
(setq py-which-shell "/usr/local/bin/python3")
as suggested here: Both Python 2 and 3 in Emacs, but that doesn't change anything (py-which-shell does get changed, but it still launches 2.7.2).
Any ideas?
Try adding the following code to your Emacs init file:
(add-hook 'python-mode-hook
(lambda ()
(setq py-python-command "python3")
(setq py-default-interpreter "python3")))
py-default-interpreter for now is an alias only, delivered for backward compatibility
You might have encountered a bug.
Please file a report giving some example code at
https://bugs.launchpad.net/python-mode
Should the buffer code contain a shebang specifying pythonVERSION , than this takes precedence over default setting.
You may enforce executing buffer through specific pythonVERSION by calling
a command of class py-execute-buffer-pythonVERSION
See menu PyExec, entry Execute buffer ...