Emacs: Use 'recompile' instead of 'compile-here'
parent
400f6ab4db
commit
644d13ff92
|
@ -21,34 +21,6 @@ sure it gets executed."
|
||||||
standard-output
|
standard-output
|
||||||
(apply 'call-process program nil t nil args))))
|
(apply 'call-process program nil t nil args))))
|
||||||
|
|
||||||
;; (defcustom compilation-after-hook nil
|
|
||||||
;; "List of hook functions run by `compile-custom'."
|
|
||||||
;; :type 'hook
|
|
||||||
;; :group 'compilation)
|
|
||||||
|
|
||||||
(defcustom compilation-before-hook nil
|
|
||||||
"List of hook functions run by `compile-custom'.
|
|
||||||
You may want to set the `compile-command' with this hook. If you
|
|
||||||
do so, do not forget to set the LOCAL flag to t."
|
|
||||||
:type 'hook
|
|
||||||
:group 'compilation)
|
|
||||||
|
|
||||||
(defvar compilation-time-before-hide-window nil
|
|
||||||
"Hide compilation window after the specified seconds.
|
|
||||||
If nil, do not hide.")
|
|
||||||
|
|
||||||
(defun compile-here (&optional runhooks)
|
|
||||||
"Call `recompile' in the default directory.
|
|
||||||
If RUNHOOKS is non-nil (or with \\[universal-argument]), run hooks in
|
|
||||||
`compilation-before-hook', then `recompile'."
|
|
||||||
(interactive "P")
|
|
||||||
(when (or runhooks (string= compile-command "make -k ")) (run-hooks 'compilation-before-hook))
|
|
||||||
(setq-default compilation-directory default-directory)
|
|
||||||
(recompile)
|
|
||||||
(when compilation-time-before-hide-window
|
|
||||||
(sit-for compilation-time-before-hide-window)
|
|
||||||
(delete-windows-on "*compilation*")))
|
|
||||||
|
|
||||||
(defun count-occurences (regex string)
|
(defun count-occurences (regex string)
|
||||||
"Return number of times regex occurs in string.
|
"Return number of times regex occurs in string.
|
||||||
If you want to operate on buffer, use `how-many' instead."
|
If you want to operate on buffer, use `how-many' instead."
|
||||||
|
|
|
@ -216,13 +216,13 @@
|
||||||
(auto-fill-mode -1))))
|
(auto-fill-mode -1))))
|
||||||
|
|
||||||
;; Compilation bindings and conveniences.
|
;; Compilation bindings and conveniences.
|
||||||
(require 'functions) ; for `compile-custom'
|
|
||||||
(setq compilation-ask-about-save nil)
|
(setq compilation-ask-about-save nil)
|
||||||
(autoload 'recompile "compile" nil t)
|
;; Don't set these bindings in mickey as we might have to override them from
|
||||||
(define-key mickey-minor-mode-map (kbd "C-<f10>") 'compile)
|
;; mode hooks.
|
||||||
(define-key mickey-minor-mode-map (kbd "<f10>") 'compile-here)
|
(global-set-key (kbd "C-<f10>") 'compile)
|
||||||
(define-key mickey-minor-mode-map (kbd "<f11>") 'previous-error)
|
(global-set-key (kbd "<f10>") 'recompile)
|
||||||
(define-key mickey-minor-mode-map (kbd "<f12>") 'next-error)
|
(global-set-key (kbd "<f11>") 'previous-error)
|
||||||
|
(global-set-key (kbd "<f12>") 'next-error)
|
||||||
|
|
||||||
;; Code browsing: make C-M-e jump to next function instead of the end of the current function.
|
;; Code browsing: make C-M-e jump to next function instead of the end of the current function.
|
||||||
(define-key mickey-minor-mode-map (kbd "C-M-e") (lambda () (interactive) (beginning-of-defun -1)))
|
(define-key mickey-minor-mode-map (kbd "C-M-e") (lambda () (interactive) (beginning-of-defun -1)))
|
||||||
|
|
|
@ -119,7 +119,7 @@ restored."
|
||||||
mode-hook
|
mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(c-set-style "ambrevar") ;; We override existing values.
|
(c-set-style "ambrevar") ;; We override existing values.
|
||||||
(add-hook 'compilation-before-hook 'cc-set-compiler nil t)
|
(cc-set-compiler)
|
||||||
(local-set-key (kbd "<f9>") 'cc-clean)
|
(local-set-key (kbd "<f9>") 'cc-clean)
|
||||||
(local-set-key (kbd "M-.") 'semantic-ia-fast-jump)
|
(local-set-key (kbd "M-.") 'semantic-ia-fast-jump)
|
||||||
(local-set-key (kbd "C-c C-d") 'semantic-ia-show-summary)
|
(local-set-key (kbd "C-c C-d") 'semantic-ia-show-summary)
|
||||||
|
|
|
@ -51,8 +51,10 @@
|
||||||
'latex-mode-hook
|
'latex-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set (make-local-variable 'tex-extension-list)
|
(set (make-local-variable 'tex-extension-list)
|
||||||
'("aux" "bbl" "blg" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "maf" "mt" "mtc" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy"))
|
'("aux" "bbl" "blg" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "maf" "mt" "mtc" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy"))
|
||||||
(set (make-local-variable 'tex-command) "pdflatex")
|
(set (make-local-variable 'tex-command) "pdflatex")
|
||||||
|
;; Need to reset the compiler because we changed tex-command.
|
||||||
|
(tex-set-compiler)
|
||||||
;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
|
;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
|
||||||
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
|
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
|
||||||
(local-set-key (kbd "C-c m") 'latex-article)
|
(local-set-key (kbd "C-c m") 'latex-article)
|
||||||
|
|
|
@ -1,29 +1,21 @@
|
||||||
;; Python
|
;; Python
|
||||||
|
|
||||||
(defun python-version ()
|
(defun python-set-compiler ()
|
||||||
"Returns \"python2\" or \"python3\" according to the shabang.
|
"Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
|
||||||
`python-shell-interpreter' is assumed by default."
|
(let* ((firstline
|
||||||
(let ((firstline
|
(save-excursion (beginning-of-buffer) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
|
||||||
(car
|
(interpreter
|
||||||
(split-string (buffer-substring-no-properties 1 (point-max)) "\n"))))
|
(if (not (string-match "^#!" firstline))
|
||||||
(if (not (string-match "^#!" firstline))
|
python-shell-interpreter
|
||||||
"python"
|
(substring firstline 2))))
|
||||||
(cond
|
(set (make-local-variable 'compile-command)
|
||||||
((string-match "python2" firstline) "python2")
|
(concat interpreter " " (shell-quote-argument buffer-file-name)))))
|
||||||
((string-match "python3" firstline) "python3")
|
|
||||||
(t python-shell-interpreter)))))
|
|
||||||
|
|
||||||
(defun python-set-interpreter ()
|
|
||||||
"Use compile to run python programs."
|
|
||||||
(interactive)
|
|
||||||
(set (make-local-variable 'compile-command)
|
|
||||||
(concat (python-version) " " (shell-quote-argument buffer-file-name))))
|
|
||||||
|
|
||||||
(add-hook-and-eval
|
(add-hook-and-eval
|
||||||
'python-mode-hook
|
'python-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set (make-local-variable 'compilation-scroll-output) t)
|
(set (make-local-variable 'compilation-scroll-output) t)
|
||||||
(add-hook 'compilation-before-hook 'python-set-interpreter nil t)))
|
(python-set-compiler)))
|
||||||
|
|
||||||
;; Doc lookup. Requires the python.info file to be installed. See
|
;; Doc lookup. Requires the python.info file to be installed. See
|
||||||
;; https://bitbucket.org/jonwaltman/pydoc-info/.
|
;; https://bitbucket.org/jonwaltman/pydoc-info/.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(setq-default sh-shell-file sh-shell-file)
|
(setq-default sh-shell-file sh-shell-file)
|
||||||
;; (setq-default sh-shell 'sh)
|
;; (setq-default sh-shell 'sh)
|
||||||
|
|
||||||
(defun sh-set-interpreter ()
|
(defun sh-set-compiler ()
|
||||||
"Set shell interpreter.
|
"Set shell interpreter.
|
||||||
Set `sh-shell', `sh-shell-file' and `compile-command' according to the following rules:
|
Set `sh-shell', `sh-shell-file' and `compile-command' according to the following rules:
|
||||||
- Look at shabang.
|
- Look at shabang.
|
||||||
|
@ -67,7 +67,7 @@ The advantages of this function over the vanilla code are:
|
||||||
(setq sh-indent-for-case-alt '+)
|
(setq sh-indent-for-case-alt '+)
|
||||||
(set (make-local-variable 'defun-prompt-regexp)
|
(set (make-local-variable 'defun-prompt-regexp)
|
||||||
(concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)"))
|
(concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)"))
|
||||||
(sh-set-interpreter)))
|
(sh-set-compiler)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,19 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Custom
|
;; Custom
|
||||||
|
|
||||||
(defcustom masterfile nil
|
(defvar-local tex-masterfile nil
|
||||||
"The file that should be compiled. Useful for modular documents."
|
"The file that should be compiled. Useful for modular documents.")
|
||||||
:safe 'stringp)
|
(defvar-local tex-compilation-delay 2
|
||||||
|
"Delay before hiding the compilation window.")
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Variables
|
;; Variables
|
||||||
|
|
||||||
(defvar tex-extension-list nil
|
(defcustom tex-extension-list nil
|
||||||
"List of known TeX exentsions. This list is used by `tex-clean'
|
"List of known TeX exentsions. This list is used by `tex-clean'
|
||||||
to purge all matching files.")
|
to purge all matching files.")
|
||||||
|
|
||||||
(defvar tex-index-command "makeindex"
|
(defcustom tex-index-command "makeindex"
|
||||||
"The TeX index file generator.")
|
"The TeX index file generator.")
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -44,8 +45,7 @@
|
||||||
(hack-local-variables)
|
(hack-local-variables)
|
||||||
(let* (;; Master file.
|
(let* (;; Master file.
|
||||||
(local-master
|
(local-master
|
||||||
|
(if tex-masterfile tex-masterfile (if buffer-file-name buffer-file-name (error "Buffer has no file name"))))
|
||||||
(if masterfile masterfile (if buffer-file-name buffer-file-name (error "Buffer has no file name"))))
|
|
||||||
(dirname (file-name-directory local-master))
|
(dirname (file-name-directory local-master))
|
||||||
(basename (file-name-sans-extension (file-name-nondirectory local-master)))
|
(basename (file-name-sans-extension (file-name-nondirectory local-master)))
|
||||||
;; Note: makeindex fails with absolute file names, we need relative names.
|
;; Note: makeindex fails with absolute file names, we need relative names.
|
||||||
|
@ -54,9 +54,9 @@
|
||||||
(concat
|
(concat
|
||||||
"cd " (if dirname (shell-quote-argument dirname) ".") " && "
|
"cd " (if dirname (shell-quote-argument dirname) ".") " && "
|
||||||
(when (executable-find tex-index-command)
|
(when (executable-find tex-index-command)
|
||||||
(concat tex-index-command " " (shell-quote-argument (concat basename ".idx")) " ; "))
|
(concat tex-index-command " " (shell-quote-argument (concat basename ".idx")) "; "))
|
||||||
(when (executable-find tex-bibtex-command)
|
(when (executable-find tex-bibtex-command)
|
||||||
(concat tex-bibtex-command " " (shell-quote-argument basename) " ; "))
|
(concat tex-bibtex-command " " (shell-quote-argument basename) "; "))
|
||||||
tex-command
|
tex-command
|
||||||
" " tex-start-options
|
" " tex-start-options
|
||||||
" " tex-start-commands
|
" " tex-start-commands
|
||||||
|
@ -68,8 +68,8 @@ but there is no warranty."
|
||||||
(interactive)
|
(interactive)
|
||||||
(hack-local-variables)
|
(hack-local-variables)
|
||||||
(let ((master (concat
|
(let ((master (concat
|
||||||
(if masterfile
|
(if tex-masterfile
|
||||||
(file-name-sans-extension masterfile)
|
(file-name-sans-extension tex-masterfile)
|
||||||
(file-name-sans-extension buffer-file-name))
|
(file-name-sans-extension buffer-file-name))
|
||||||
".")))
|
".")))
|
||||||
(mapcar
|
(mapcar
|
||||||
|
@ -84,19 +84,19 @@ but there is no warranty."
|
||||||
tex-extension-list))))
|
tex-extension-list))))
|
||||||
|
|
||||||
(defun tex-pdf-compress ()
|
(defun tex-pdf-compress ()
|
||||||
"Use `masterfile' variable as default value for `pdf-compress'."
|
"Use `tex-masterfile' variable as default value for `pdf-compress'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(require 'tool-pdf)
|
(require 'tool-pdf)
|
||||||
(hack-local-variables)
|
(hack-local-variables)
|
||||||
(let ((local-master (if masterfile masterfile buffer-file-name)))
|
(let ((local-master (if tex-masterfile tex-masterfile buffer-file-name)))
|
||||||
(pdf-compress local-master)))
|
(pdf-compress local-master)))
|
||||||
|
|
||||||
(defun tex-pdf-view ()
|
(defun tex-pdf-view ()
|
||||||
"Use `masterfile' variable as default value for `pdf-view'."
|
"Use `tex-masterfile' variable as default value for `pdf-view'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(require 'tool-pdf)
|
(require 'tool-pdf)
|
||||||
(hack-local-variables)
|
(hack-local-variables)
|
||||||
(let ((local-master (if masterfile masterfile buffer-file-name)))
|
(let ((local-master (if tex-masterfile tex-masterfile buffer-file-name)))
|
||||||
(pdf-view local-master)))
|
(pdf-view local-master)))
|
||||||
|
|
||||||
(defun tex-toggle-escape-char ()
|
(defun tex-toggle-escape-char ()
|
||||||
|
@ -113,10 +113,12 @@ This does not interfere with `subword-mode'."
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; TeX setup
|
;; TeX setup
|
||||||
|
|
||||||
(setq tex-start-options "-file-line-error-style -interaction=nonstopmode -synctex=1 ")
|
(setq-default tex-command "pdftex")
|
||||||
|
(setq tex-command "pdftex")
|
||||||
|
(setq-default tex-start-options "-file-line-error-style -interaction=nonstopmode -synctex=1")
|
||||||
;; Use the following variable to append file local commands without erasing
|
;; Use the following variable to append file local commands without erasing
|
||||||
;; default options.
|
;; default options.
|
||||||
(setq tex-start-commands nil)
|
(setq-default tex-start-commands nil)
|
||||||
|
|
||||||
(add-hook-and-eval
|
(add-hook-and-eval
|
||||||
'tex-mode-hook
|
'tex-mode-hook
|
||||||
|
@ -129,13 +131,12 @@ This does not interfere with `subword-mode'."
|
||||||
(local-unset-key key))
|
(local-unset-key key))
|
||||||
(set-face-attribute 'tex-verbatim nil :family "freemono")
|
(set-face-attribute 'tex-verbatim nil :family "freemono")
|
||||||
(set (make-local-variable 'compilation-scroll-output) t)
|
(set (make-local-variable 'compilation-scroll-output) t)
|
||||||
(set (make-local-variable 'compilation-time-before-hide-window) 2)
|
|
||||||
(set (make-local-variable 'paragraph-start) "
|
(set (make-local-variable 'paragraph-start) "
|
||||||
")
|
")
|
||||||
;; (set (make-local-variable 'use-hard-newlines) t)
|
;; (set (make-local-variable 'use-hard-newlines) t)
|
||||||
(local-set-key (kbd "<f9>") 'tex-pdf-view)
|
(local-set-key (kbd "<f9>") 'tex-pdf-view)
|
||||||
(setq tex-command "pdftex")
|
(local-set-key (kbd "<f10>") (lambda () (interactive) (progn (recompile) (sit-for tex-compilation-delay) (delete-windows-on "*compilation*"))))
|
||||||
(add-hook 'compilation-before-hook 'tex-set-compiler nil t)))
|
(tex-set-compiler)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Skeletons
|
;; Skeletons
|
||||||
|
|
Loading…
Reference in New Issue