Emacs and CWB under Windows - emacs

I'm trying to use the Edinburgh Concurrency Workbench (http://homepages.inf.ed.ac.uk/perdita/cwb/) with Emacs under Windows. I have placed the file cwb.el under C:\emacs\emacs-22.3\emacs-stuff. My .emacs file is located at C:\emacs and has the following content:
(setq load-path ; Look in my own library first.
(cons (expand-file-name "C:\emacs\emacs-22.3\emacsstuff")
load-path))
(autoload 'cwb "cwb" "Run a CWB process." t)
(autoload 'cwb-file-mode "cwb" "Major mode for editing CWB source." t)
(add-hook 'cwb-load-hook
(function
(lambda ()
(setq cwb-program-name "cwb7")))) ;; only necessary if your v7 isn't
;; called cwb
Yet, when I enter "M-x cwb", I get "Cannot open load file: cwb".
I tried to follow the instruction here: http://homepages.inf.ed.ac.uk/perdita/cwb/doc/emacs.html.
Thanks

In Emacs Lisp strings, backslash is an escape character, similar to C, so "C:\emacs\emacs-22.3\emacsstuff" ends up being "C:^[macs^[macs-22.3^[macsstuff". (You can try it with either M-: or M-x ielm.)
You can either write the path with forward slashes instead ("C:/emacs/emacs-22.3/emacsstuff") or use double backslashes ("C:\\emacs\\emacs-22.3\\emacsstuff").

Related

Unable to run emacs in `magit-status-mode` with using custom initialization file

I like to use terminal tools and the one of them is 'magit' - awesome Git client implemented as an Emacs package. I use it to control Git projects. I have a script which automatically start emacs at computer boot (this same me a time with routine work). But also I'm looking for a way to run emacs in magit-status mode (without manual executing M-x magit-status... each time). Emacs provide a possibility to configure it's environment in init configuration file. To make emacs run magit at boot I created special magit.el file and run emacs from command line
$ emacs -q --load ~/.emacs.d/magit.el
Unfortunately I unable to switch emacs in magic-status-mode - something wrong with init file. Emacs remains in lisp-interaction-mode after boot. The content of init file is below:
;; disable welcome screen at launch
(setq inhibit-startup-screen t)
(setq visible-bell t)
; Disable tabs indent
(setq-default c-basic-offset 4
tab-width 4
indent-tabs-mode nil)
(global-set-key "\C-h" 'delete-backward-char)
;; Makes *scratch* empty.
(setq initial-scratch-message "")
;; Removes *scratch* from buffer after the mode has been set.
(defun remove-scratch-buffer ()
(if (get-buffer "*scratch*")
(kill-buffer "*scratch*")))
;(add-hook 'after-change-major-mode-hook 'remove-scratch-buffer)
;; Removes *messages* from the buffer.
;(setq-default message-log-max nil)
;(kill-buffer "*Messages*")
;; Removes *Completions* from buffer after you've opened a file.
;(add-hook 'minibuffer-exit-hook
; '(lambda ()
; (let ((buffer "*Completions*"))
; (and (get-buffer buffer)
; (kill-buffer buffer)))))
;; Don't show *Buffer list* when opening multiple files at the same time.
(setq inhibit-startup-buffer-menu t)
;; Show only one active window when opening multiple files at the same time.
;(add-hook 'window-setup-hook 'delete-other-windows)
;; Tell emacs where is your personal elisp lib dir (magit)
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "git") ;; best not to include the ending “.el” or “.elc”
;; activate installed packages
(package-initialize)
(setq-default major-mode 'magit-status-mode)
(add-hook 'after-init-hook #'magit-status-mode)
(if after-init-time
(add-hook 'after-init-hook #'magit-status-mode))
Try this:
(call-interactively 'magit-status)
Instead of all of this:
(setq-default major-mode 'magit-status-mode)
(add-hook 'after-init-hook #'magit-status-mode)
(if after-init-time
(add-hook 'after-init-hook #'magit-status-mode))
Using after-init-hook would make sense in an init file, but with -q you're explicitly not using an init file (using --load is not the same thing), and that hook has already run by the time your custom magit.el file is loaded, so nothing you add to the hook at that stage will ever be processed.
Note that you don't want to call magit-status-mode at all. That's not a major mode you would ever be expected to invoke manually, as you would never want that mode for any buffer other than the one created by the magit-status command.

One-shot command to knit and latexmk under Emacs + AUCtex

I want to knit AND latexmk Knitr documents using one AUCtex command.
I don't know how to code in lisp, and web search didn't turn up anything like this.
I have something close. The extension of the file needs to be changed for latexmk.
Any help will be appreciated.
Following line is for my .emacs file.
(add-hook 'LaTeX-mode-hook (lambda () (push '
("KnitrLaTeX" "Rscript -e \"library(knitr)\; knit('%s')\" && latexmk -pdf %s"
TeX-run-TeX nil t :help "Run knitr and latexmk on file")
TeX-command-list)))
When I run C-c C-c (KnitrLaTeX), emacs runs the following command:
Running `KnitrLaTeX' on `slides.Rnw' with ``Rscript -e "library(knitr); knit('slides.Rnw')" && latexmk -pdf slides.Rnw''
Which is wrong. It should read "... && latexmk -pdf slides.tex"
Thanks in advance.
It appears that you are having trouble with how the second usage of %s is being interpreted at the tail end of your compile command -- i.e., you want the second usage of %s to mean slides.tex instead of slides.Rnw.
Although I am not familiar with knit, I am familiar with creating custom variables for use with AUCTeX. Set forth below are some examples of how to create custom variables and add them to the TeX-expand-list.
Rather than of using %s for a second time (i.e., at the tail end of your compilation command), perhaps consider using %(tex-file-name) instead. This assumes that your *.tex file is open in the buffer with focus when you begin your compilation command -- i.e., the full file name will be inserted into your compilation command.
If you have a file with a different extension that is open in the buffer with focus when you run your compilation command, and if you want the base name to be the same (but with a different extension), then you would do something similar to the example of %(pdf-file-name) -- i.e., remove whatever extension is there and replace it with the new one.
(eval-after-load "tex" '(progn
(add-to-list 'TeX-expand-list '("%(tex-file-name)" (lambda ()
(concat "\"" (buffer-file-name) "\""))))
(add-to-list 'TeX-expand-list '("%(pdf-file-name)" (lambda ()
(concat
"\"" (car (split-string (buffer-file-name) "\\.tex"))
".pdf" "\""))))
(add-to-list 'TeX-expand-list '("%(line-number)" (lambda ()
(format "%d" (line-number-at-pos))))) ))

Emacs Auctex compile error: "Use M-x make-directory RET RET to create the directory and its parents"

I am running emacs 23.3.1 on ubuntu 12.04 with auctex 11.86. Whenever I go to compile a latex document (using C-c C-c), if there are no errors, everything compiles just fine. However, if there are any errors it will tell me to use C-` to view errors, if I do so, I get this error message
Use M-x make-directory RET RET to create the directory and its parents
and it goes away after a couple seconds. Then it takes me to another screen that explains the error in the latex code. However, now I cannot simply do C-x 1 to get back to the latex code. I have to C-x C-c and restart emacs.
This is my .emacs file
(setq backup-by-copying t
backup-directory-alist '(("." . "~/.emacsBkups"))
delete-old-versions t
kept-new-versions 5
kept-old-versions 2
version-control t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
;;(require 'ess-site)
;;(ess-toggle-underscore nil)
(require 'whitespace)
(setq whitespace-style '(lines-tail face))
(add-hook 'c-mode-hook 'whitespace-mode)
(add-hook 'c++-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(c-set-offset (quote cpp-macro) 0 nil)
(setq TeX-view-program-list '(("Evince" "evince --page-index=%(outpage) %o")))
(setq TeX-view-program-selection '((output-pdf "Evince")))
Sometimes AUCTeX gets confused parsing the log of (La)TeX compilation and isn't able to guess the correct line raising the error. In some cases AUCTeX issues an obscure message "Error occured after last TeX file closed", when there are unbalanced parentheses, in your case it suggests you to create a new directory. To help AUCTeX finding the correct line raising the error you can add the -file-line-error option to latex or pdflatex by customizing the variable LaTeX-command-style. To do this add the following code to your .emacs:
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error %S%(PDFout)")))
See also the AUCTeX FAQ:
8. Why does TeX-next-error (C-c `) fail?
When writing the log file, TeX puts information related to a file,
including error messages, between a pair of parentheses. AUCTeX
determines the file where the error happened by parsing the log file
and counting the parentheses. This can fail when there are other,
unbalanced parentheses present.
As a workaround you can activate so-called file:line:error messages
for the log file. (Those are are easier to parse, but may lack some
details.) Either you do this in the configuration of your TeX system
(consult its manual to see where this is) or you add a command line
switch to the (la)tex call, e.g. by customizing LaTeX-command-style or
TeX-command-list.

change .emacs file's location

I am working on windows xp
I stored emacs in usb
I want to carry the .emacs file as well as binary files
what I tried are
(setenv “HOME” (format "%s" (getenv "emacspath")))
(setenv “HOME” (format "%s/" (getenv "emacspath")))
It seems works if I eval-expression in emacs
After setenv, I could notice setting env is works well by (getenv "home")
but I put the (setenv "home" (format "%s/" (getenv "emacspath")))
in "site-start.el" file in "site-lisp" folder, starting emacs says "Symbol's value as variable is void: "HOME"
Any ideas?
An easier way - just create a batch file on your USB drive where you can set all env variables you need. Then start emacs.exe from the batch.
For example if you want to run SBCL add the following lines to your batch
rem SBCL_HOME is required for SBCL
set SBCL_HOME=%utils%\Lisp\sbcl\1.0.29
set SBCL_RUN=%SBCL_HOME%\sbcl.exe
set SBCL_OPTIONS=--noinform
How about using default.el either as a symlink or as a simple elisp pinter to your file:
(load-file "/path/to/usb/.emacs")
Add following code to a file (e.g. c:/.emacs).
;; This function must be at begin
(defun zxy-relocate-dotemacs ()
"Relocate .emacs file"
(interactive)
(with-temp-buffer
(let (print-level print-length)
(insert (format "(load-file \"%s\")" load-file-name))
(if (file-exists-p "~/.emacs")
(message "[zxy] Don't need relocate .emacs file!")
(progn
(message "[zxy] Relocate .emacs file.")
(write-file "~/.emacs"))))))
(zxy-relocate-dotemacs)
;; Your configuration here
Open emacs and M-x load-file c:/.emacs.
Then it will relocate .emacs to c:/.emacs.
I use this when I copy my emacs to a new computer.
More information please visit my blog abuot emacs.
http://coordinate.sinaapp.com/?cat=3

Loading fic-mode in emacs

This answer gave me the solution I needed. The only problem for me, is that I have to load it, namely fic-mode, manually. More explicitly, whenever I open a c++ file, I have to do M-x fic-mode and then M-x font-lock-fontify-buffer in order to have it really up and running. In my .emacs I have
(require 'fic-mode)
(add-hook 'c++-mode-hook '(lambda () (fic-mode 1)))
but it doesn't do the trick.
Do you have any suggestions how to make it available automatically?
Try the following: create a new file containing the following three lines:
(setq load-path (cons "/path/to/fic-mode-directory" load-path))
(require 'fic-mode)
(add-hook 'c++-mode-hook 'turn-on-fic-mode)
Replace "/path/to/fic-mode-directory" with the absolute path to the directory in which you saved fic-mode.el.
Then from the command line, run
emacs -Q -l /path/to/file
where /path/to/file is the path to the above file.
Now type C-x C-f test.cpp.
Is fic-mode turned on in the resulting buffer?