Emacs: Use 'recompile' instead of 'compile-here'
parent
400f6ab4db
commit
644d13ff92
|
@ -21,34 +21,6 @@ sure it gets executed."
|
|||
standard-output
|
||||
(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)
|
||||
"Return number of times regex occurs in string.
|
||||
If you want to operate on buffer, use `how-many' instead."
|
||||
|
|
|
@ -216,13 +216,13 @@
|
|||
(auto-fill-mode -1))))
|
||||
|
||||
;; Compilation bindings and conveniences.
|
||||
(require 'functions) ; for `compile-custom'
|
||||
(setq compilation-ask-about-save nil)
|
||||
(autoload 'recompile "compile" nil t)
|
||||
(define-key mickey-minor-mode-map (kbd "C-<f10>") 'compile)
|
||||
(define-key mickey-minor-mode-map (kbd "<f10>") 'compile-here)
|
||||
(define-key mickey-minor-mode-map (kbd "<f11>") 'previous-error)
|
||||
(define-key mickey-minor-mode-map (kbd "<f12>") 'next-error)
|
||||
;; Don't set these bindings in mickey as we might have to override them from
|
||||
;; mode hooks.
|
||||
(global-set-key (kbd "C-<f10>") 'compile)
|
||||
(global-set-key (kbd "<f10>") 'recompile)
|
||||
(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.
|
||||
(define-key mickey-minor-mode-map (kbd "C-M-e") (lambda () (interactive) (beginning-of-defun -1)))
|
||||
|
|
|
@ -119,7 +119,7 @@ restored."
|
|||
mode-hook
|
||||
(lambda ()
|
||||
(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 "M-.") 'semantic-ia-fast-jump)
|
||||
(local-set-key (kbd "C-c C-d") 'semantic-ia-show-summary)
|
||||
|
|
|
@ -51,8 +51,10 @@
|
|||
'latex-mode-hook
|
||||
(lambda ()
|
||||
(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")
|
||||
;; 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.
|
||||
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
|
||||
(local-set-key (kbd "C-c m") 'latex-article)
|
||||
|
|
|
@ -1,29 +1,21 @@
|
|||
;; Python
|
||||
|
||||
(defun python-version ()
|
||||
"Returns \"python2\" or \"python3\" according to the shabang.
|
||||
`python-shell-interpreter' is assumed by default."
|
||||
(let ((firstline
|
||||
(car
|
||||
(split-string (buffer-substring-no-properties 1 (point-max)) "\n"))))
|
||||
(if (not (string-match "^#!" firstline))
|
||||
"python"
|
||||
(cond
|
||||
((string-match "python2" firstline) "python2")
|
||||
((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))))
|
||||
(defun python-set-compiler ()
|
||||
"Returns the value of the shebang if any, `python-shell-interpreter' otherwise."
|
||||
(let* ((firstline
|
||||
(save-excursion (beginning-of-buffer) (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
|
||||
(interpreter
|
||||
(if (not (string-match "^#!" firstline))
|
||||
python-shell-interpreter
|
||||
(substring firstline 2))))
|
||||
(set (make-local-variable 'compile-command)
|
||||
(concat interpreter " " (shell-quote-argument buffer-file-name)))))
|
||||
|
||||
(add-hook-and-eval
|
||||
'python-mode-hook
|
||||
(lambda ()
|
||||
(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
|
||||
;; https://bitbucket.org/jonwaltman/pydoc-info/.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(setq-default sh-shell-file sh-shell-file)
|
||||
;; (setq-default sh-shell 'sh)
|
||||
|
||||
(defun sh-set-interpreter ()
|
||||
(defun sh-set-compiler ()
|
||||
"Set shell interpreter.
|
||||
Set `sh-shell', `sh-shell-file' and `compile-command' according to the following rules:
|
||||
- Look at shabang.
|
||||
|
@ -67,7 +67,7 @@ The advantages of this function over the vanilla code are:
|
|||
(setq sh-indent-for-case-alt '+)
|
||||
(set (make-local-variable 'defun-prompt-regexp)
|
||||
(concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)"))
|
||||
(sh-set-interpreter)))
|
||||
(sh-set-compiler)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
|
|
@ -21,18 +21,19 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Custom
|
||||
|
||||
(defcustom masterfile nil
|
||||
"The file that should be compiled. Useful for modular documents."
|
||||
:safe 'stringp)
|
||||
(defvar-local tex-masterfile nil
|
||||
"The file that should be compiled. Useful for modular documents.")
|
||||
(defvar-local tex-compilation-delay 2
|
||||
"Delay before hiding the compilation window.")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Variables
|
||||
|
||||
(defvar tex-extension-list nil
|
||||
(defcustom tex-extension-list nil
|
||||
"List of known TeX exentsions. This list is used by `tex-clean'
|
||||
to purge all matching files.")
|
||||
|
||||
(defvar tex-index-command "makeindex"
|
||||
(defcustom tex-index-command "makeindex"
|
||||
"The TeX index file generator.")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -44,8 +45,7 @@
|
|||
(hack-local-variables)
|
||||
(let* (;; Master file.
|
||||
(local-master
|
||||
|
||||
(if masterfile masterfile (if buffer-file-name buffer-file-name (error "Buffer has no file name"))))
|
||||
(if tex-masterfile tex-masterfile (if buffer-file-name buffer-file-name (error "Buffer has no file name"))))
|
||||
(dirname (file-name-directory local-master))
|
||||
(basename (file-name-sans-extension (file-name-nondirectory local-master)))
|
||||
;; Note: makeindex fails with absolute file names, we need relative names.
|
||||
|
@ -54,9 +54,9 @@
|
|||
(concat
|
||||
"cd " (if dirname (shell-quote-argument dirname) ".") " && "
|
||||
(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)
|
||||
(concat tex-bibtex-command " " (shell-quote-argument basename) " ; "))
|
||||
(concat tex-bibtex-command " " (shell-quote-argument basename) "; "))
|
||||
tex-command
|
||||
" " tex-start-options
|
||||
" " tex-start-commands
|
||||
|
@ -68,8 +68,8 @@ but there is no warranty."
|
|||
(interactive)
|
||||
(hack-local-variables)
|
||||
(let ((master (concat
|
||||
(if masterfile
|
||||
(file-name-sans-extension masterfile)
|
||||
(if tex-masterfile
|
||||
(file-name-sans-extension tex-masterfile)
|
||||
(file-name-sans-extension buffer-file-name))
|
||||
".")))
|
||||
(mapcar
|
||||
|
@ -84,19 +84,19 @@ but there is no warranty."
|
|||
tex-extension-list))))
|
||||
|
||||
(defun tex-pdf-compress ()
|
||||
"Use `masterfile' variable as default value for `pdf-compress'."
|
||||
"Use `tex-masterfile' variable as default value for `pdf-compress'."
|
||||
(interactive)
|
||||
(require 'tool-pdf)
|
||||
(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)))
|
||||
|
||||
(defun tex-pdf-view ()
|
||||
"Use `masterfile' variable as default value for `pdf-view'."
|
||||
"Use `tex-masterfile' variable as default value for `pdf-view'."
|
||||
(interactive)
|
||||
(require 'tool-pdf)
|
||||
(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)))
|
||||
|
||||
(defun tex-toggle-escape-char ()
|
||||
|
@ -113,10 +113,12 @@ This does not interfere with `subword-mode'."
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; 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
|
||||
;; default options.
|
||||
(setq tex-start-commands nil)
|
||||
(setq-default tex-start-commands nil)
|
||||
|
||||
(add-hook-and-eval
|
||||
'tex-mode-hook
|
||||
|
@ -129,13 +131,12 @@ This does not interfere with `subword-mode'."
|
|||
(local-unset-key key))
|
||||
(set-face-attribute 'tex-verbatim nil :family "freemono")
|
||||
(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 'use-hard-newlines) t)
|
||||
(local-set-key (kbd "<f9>") 'tex-pdf-view)
|
||||
(setq tex-command "pdftex")
|
||||
(add-hook 'compilation-before-hook 'tex-set-compiler nil t)))
|
||||
(local-set-key (kbd "<f10>") (lambda () (interactive) (progn (recompile) (sit-for tex-compilation-delay) (delete-windows-on "*compilation*"))))
|
||||
(tex-set-compiler)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Skeletons
|
||||
|
|
Loading…
Reference in New Issue