Personal GNU Emacs configuration file.
This configuration sets up several non-built-in packages, namely
- Solarized (color theme)
- Gettext PO mode
- AUCTeX
- ESS
although none of them are required.
Saving this file with Emacs will automatically generate the
initialization file init.el
and compile it. To generate init.el
manually, type M-x org-babel-tangle
in this buffer.
In Emacs Lisp, key sequences can be represented in various forms (see
Key Sequences in the GNU Emacs Lisp Reference manual). In this file,
we shall use the vector format, whereby key sequences are represented
as [event1 event2 ...]
where eventN
is an event in Lisp form:
- Single characters:
?a
?b
?c
… - Event modifiers (escape format):
\C-
\M-
- Event modifiers (in lists):
meta
control
shift
hyper
super
alt
- Function keys:
backspace
tab
newline
return
delete
left
up
right
down
f1
f2
f3
…
Examples: [(control ?x) ?l]
(same as [?\C-x ?l]
), [backspace]
,
[(hyper left)]
…
The following key sequences are not bound in GNU Emacs, by default:
M-+
M-¡
M-S-¡
- ~M-S-‘~
M-ñ
M-S-ñ
M-ç
M-S-ç
M-S-<a-z>
;; init.el -- configuration file for GNU Emacs
;;
;; Automatically generated, do not edit.
;; automatically added by package.el
;; (package-initialize)
(defconst windows-system-p (eq system-type 'windows-nt)
"Non-nil if Emacs is running on a Microsoft Windows operating system.")
Add the lisp/
subdirectory under the user’s Emacs directory, as well
as its subdirectories, to the search path.
(let ((default-directory
(expand-file-name "lisp" user-emacs-directory)))
(add-to-list 'load-path default-directory)
(normal-top-level-add-subdirs-to-load-path))
Add $XDG_DATA_HOME/emacs/site-lisp
(on Windows
%appdata%/emacs/site-lisp
), as well as all its subdirectories, to the
search path.
(let* ((path (cond ((eq system-type 'gnu/linux)
(or (getenv "XDG_DATA_HOME")
(expand-file-name "~/.local/share")))
((eq system-type 'windows-nt)
(or (getenv "appdata") ""))
(t "")))
(default-directory (concat (file-name-as-directory path)
(file-name-as-directory "emacs")
"site-lisp")))
(unless (string= path "")
(add-to-list 'load-path default-directory)
(normal-top-level-add-subdirs-to-load-path)))
Prevent Emacs from loading obselete bytecode files. Notice that this
will not prevent Emacs from loading an obsolete ./init.elc
.
(setq load-prefer-newer t)
Store customizations in a separate file.
(setq custom-file (expand-file-name
"customizations" user-emacs-directory))
Load existing customizations.
(when (file-exists-p custom-file)
(load custom-file))
Store custom themes in the themes/
subdirectory under the user’s Emacs
directory.
(setq custom-theme-directory
(expand-file-name "themes" user-emacs-directory))
Add the theme’s subdirectory to the search path.
(add-to-list
'custom-theme-load-path
(concat (file-name-as-directory custom-theme-directory)
(file-name-as-directory "solarized")))
Override face difinitions with our own.
(defvar solarized-custom-color-definitions nil
"A list of face definitions, overriding the theme definitions.
Each element is a list of the form
(FACE SPEC)
where FACE is a face name, and SPEC is a face specification that
can include Solarized colors.")
(defun solarized-merge-custom-color-definitions (defs)
"Update DEFS with new definitions from
`solarized-custom-color-definitions' and return the result."
(dolist (newdef solarized-custom-color-definitions defs)
(setq defs (cons (apply 'create-face-spec newdef)
(assq-delete-all (car newdef) defs)))))
(advice-add 'solarized-color-definitions :filter-return
'solarized-merge-custom-color-definitions)
(setq solarized-custom-color-definitions
'((match (:foreground base1 :inverse-video t))
(isearch (:foreground cyan :background back :inverse-video t))
;; (whitespace-tab (:foreground base01 :background base02))
(message-cited-text (:inherit font-lock-comment-face))
(message-header-cc (:inherit font-lock-keyword-face))
(message-header-name (:inherit font-lock-keyword-face))
(message-header-newsgroups (:inherit font-lock-keyword-face))
(message-header-other (:inherit font-lock-keyword-face))
(message-header-subject (:inherit font-lock-keyword-face))
(message-header-to (:inherit font-lock-keyword-face))
(message-header-xheader (:inherit font-lock-keyword-face))
(gnus-header-content (:inherit font-lock-keyword-face))
(gnus-header-from (:inherit font-lock-keyword-face))
(gnus-header-name (:inherit font-lock-keyword-face))
(gnus-header-newsgroups (:inherit font-lock-keyword-face))
(gnus-header-subject (:inherit font-lock-keyword-face))))
Uncomment to stop Solarized from displaying bold.
;; (setq solarized-bold nil)
Use 256 colours in terminals that support 256 colours.
(let ((term (getenv-internal "TERM" initial-environment)))
(cond ((string= term "xterm-256color")
(setq solarized-termcolors 256))))
Enable theme, if it’s available.
(defun solarized-enable (&optional args)
"Enable theme Solarized. Arguments are ignored."
(enable-theme 'solarized))
(when (memq 'solarized (custom-available-themes))
(add-hook 'after-make-frame-functions 'solarized-enable t)
(add-hook 'window-setup-hook 'solarized-enable t)
;; this should come at the very end
(load-theme 'solarized t t))
Instead of the current locale, use the C locale (en_US
) for displaying
date and time strings.
(setq system-time-locale "C")
Inhibit start-up screen.
(setq inhibit-startup-message t)
Auto-save every 300 input events and after 60 seconds of idle time.
(setq auto-save-default t)
(setq auto-save-interval 300)
(setq auto-save-timeout 60)
Disable automatic backups.
(setq make-backup-files nil)
Remember minibuffer input across sessions.
(savehist-mode 1)
Uncomment to increase the maximum length of history lists.
;; (setq history-length 500)
Uncomment to remove duplicated entries from the minibuffer history.
;; (setq history-delete-duplicates t)
Remember search strings across sessions.
(with-eval-after-load 'savehist
(add-to-list 'savehist-additional-variables 'search-ring)
(add-to-list 'savehist-additional-variables 'regexp-search-ring))
Type C-p
, C-n
to navigate through the minibuffer history ring (M-p
,
M-n
, matching the current input) while in the minibuffer.
(let ((map minibuffer-local-map))
(define-key map [(meta ?p)] 'previous-complete-history-element)
(define-key map [(meta ?n)] 'next-complete-history-element)
(define-key map [(control ?p)] 'previous-history-element)
(define-key map [(control ?n)] 'next-history-element))
Uncomment to save the kill ring across sessions.
;; (with-eval-after-load 'savehist
;; (add-to-list 'savehist-additional-variables 'kill-ring))
Jump to the last known point position when opening a file.
(require 'saveplace)
(save-place-mode)
(setq save-place-limit 1000)
Limit size of mini-window to 2 lines.
(setq max-mini-window-height 2)
Non-audible bell.
(setq visible-bell t)
Non-blinking cursor.
(blink-cursor-mode -1)
Show column number in mode line
(column-number-mode 1)
Show tabs and trailing space by default, in whitespace mode.
(setq whitespace-style '(face trailing tabs tab-mark))
Change the frame background mode according to the value of the
variable background-mode
. Themes may use different color schemes
depending on the value of this parameter.
(defvar background-mode nil
"Background-mode property value for frames; a symbol specifying
a MODE, either nil, `light' or `dark', or a list with elements
(TERMINAL-TYPE . MODE)
where TERMINAL-TYPE is one of `graphic' or `tty'.")
(defun set-background-mode (&optional frame)
"Set FRAME's background-mode property depending on the value of
`background-mode'. If FRAME is nil, set the property on the
current frame."
(let* ((frame (selected-frame))
(graphic-display (display-graphic-p))
(terminal-type (if graphic-display 'graphic 'tty))
(value (if (listp background-mode)
(cdr (assq terminal-type background-mode))
background-mode)))
(set-frame-parameter frame 'background-mode value)
(unless graphic-display
(set-terminal-parameter frame 'background-mode value))))
(add-hook 'window-setup-hook 'set-background-mode)
(add-hook 'after-make-frame-functions 'set-background-mode)
Set background to “dark” for tty frames.
(add-to-list 'background-mode (cons 'tty 'light))
Set the default frame size. Also, disable scrollbars, the toolbar and the menu bar. This overrides X resource settings.
(dolist (par (list
(cons 'height 31)
(cons 'width 81)
(cons 'vertical-scroll-bars nil)
(cons 'horizontal-scroll-bars nil)
(cons 'menu-bar-lines 0)
(cons 'tool-bar-lines 0)))
(push par default-frame-alist))
Set background to “light”.
(add-to-list 'background-mode (cons 'graphic 'light))
Set frame (window) title. This overrides X resource settings.
(setq frame-title-format (format "%%b - Emacs %s" emacs-version))
In graphic frames, use 11 point Monospace for displaying text in the frame. This overrides X resource settings.
(setf (alist-get 'font (alist-get 'x window-system-default-frame-alist))
"Monospace-11")
On Windows, use 11 point Consolas.
(setf (alist-get 'font (alist-get 'w32 window-system-default-frame-alist))
"Consolas-11")
Draw underlines at the descent level, rather than at the baseline level.
(setq x-underline-at-descent-line t)
Show buffer boundaries in the fringe.
(setq-default
indicate-buffer-boundaries
(list
(cons 'top 'left)
(cons 'bottom 'left)
(cons 'up 'right)
(cons 'down 'right)))
Allow “y” and “n” in yes-or-no questions.
(fset 'yes-or-no-p 'y-or-n-p)
Ask for confirmation before creating new buffers and files.
(setq confirm-nonexistent-file-or-buffer t)
Type C-x k
to kill the current buffer.
(global-set-key [(control ?x) ?k] 'kill-this-buffer)
Enable file-name shadowing in minibuffers.
(file-name-shadow-mode 1)
Type F5
to revert/refresh the current buffer.
(global-set-key [f5] 'revert-buffer)
Enable dired mode. Type C-d
in the find file prompt to open a Dired
buffer.
(require 'dired)
Type F5
in a Dired buffer to refresh its contents.
(defun dired-refresh-buffer ()
"Refresh Dired buffer without prompting for confirmation."
(interactive)
(unless (string= major-mode "dired-mode")
(error "Not a Dired buffer"))
(revert-buffer nil t)
(message "Directory listing updated."))
(define-key dired-mode-map [f5] 'dired-refresh-buffer)
Omit dot-files from directory listings. Type C-x M-o
to show them.
(require 'dired-x)
(setq dired-omit-files
(concat dired-omit-files "\\|^\\..+$"))
(add-hook 'dired-mode-hook
(lambda () (dired-omit-mode 1)))
Uncomment to keep a list of recently opened files. Type M-x
recentf-cleanup
to clean up the list of recent files manually (i.e.,
to remove duplicates, excluded files, and so on, from the list).
;; (require 'recentf)
;; (recentf-mode)
;; (setq recentf-max-menu-items 10)
;; (setq recentf-max-saved-items recentf-max-menu-items)
;; (setq recentf-exclude
;; '("\\.ido\\.last\\'"
;; "\\.git/COMMIT_EDITMSG\\'"
;; "/tmp/mutt-[^/]*\\'"
;; "\\.mozilla/firefox/[^/]*\\.default/itsalltext/[^/]*\\.txt"))
Type M-x recentf-open-files
to open the recent files buffer.
Currently unbound because C-x g
is used by Magit.
;; (global-set-key [(control ?x) ?g] 'recentf-open-files)
Preserve point position on the screen while scrolling.
(setq scroll-preserve-screen-position t)
Prevent “jumps”.
(setq scroll-margin 1
scroll-step 1
scroll-conservatively 500)
Type TAB
for symbol completion. If the current line isn’t already
indented, indent the current line instead. Some programming language
modes do not respect this variable.
(setq tab-always-indent 'complete)
Type M-/
(dabbrev-expand
) and C-M-/
(dabbrev-complete
) to expand the
word at point. This is the default.
Ignore case when completing file names
(setq read-file-name-completion-ignore-case t)
Ignore case when completing buffer names
(setq read-buffer-completion-ignore-case t)
When completing file names, exclude dot-files from the completion list, unless the file name being completed itself starts with a dot.
(defun completion-f-n-table-ignoring-dot-prefix (fun str pred flag)
"Call `completion-file-name-table' with a predicate that
ignores matches matches starting with a dot, unless STR starts
with a dot."
(funcall fun str
(cond ((string-prefix-p "." (file-name-nondirectory str))
pred)
((not pred)
(lambda (str)
(not (string-prefix-p "." str))))
(t
(lambda (str)
(and (not (string-prefix-p "." str))
(funcall pred str)))))
flag))
(advice-add 'completion-file-name-table :around
'completion-f-n-table-ignoring-dot-prefix)
Type M-v
while in the mini-buffer, to switch to the completion list
buffer. This is the default. In the completion list buffer, type p
and n
to walk through the elements in the list.
(let ((map completion-list-mode-map))
(define-key map [?p] 'previous-completion)
(define-key map [?n] 'next-completion))
Uncomment to enable file name and buffer name completion with ido.
;; (require 'ido)
;; (ido-mode 1)
;; (ido-everywhere 1)
Uncomment to skip confirmation when creating new buffers — it only
has effect when confirm-nonexistent-file-or-buffer
is nil
.
;; (setq ido-create-new-buffer 'always)
Type TAB
to cycle through suggestions.
(setq ido-report-no-match nil)
(setq ido-cannot-complete-command 'ido-next-match) ; cycle
Exclude dot files from the suggestions list.
(with-eval-after-load 'ido
(add-to-list 'ido-ignore-files "\\`\\."))
Exclude files not in the current directory from the suggestions list.
(setq ido-auto-merge-work-directories-length -1)
Match arbitrary substrings except when completing file names.
(setq ido-enable-prefix nil) ; this is the default
(defun ido-enable-prefix-if-file-dir ()
(defvar ido-cur-item) ; compiler warning
(when (memq ido-cur-item '(file dir))
(setq ido-enable-prefix t)))
(add-hook 'ido-setup-hook 'ido-enable-prefix-if-file-dir)
Do not match dots in file names except at the beginning. Commented out because it’s redudant.
;; (setq ido-enable-dot-prefix t)
Do not keep directory history.
(setq ido-enable-last-directory-history nil)
Re-bind C-p
to previous-history-element
for consistency. Also remap
ido-toggle-prefix
(bound to C-p
by default) to C-o
.
;; this needs to be in a hook because ido-completion-map is created from
;; scratch every time ido is invoked
(defun remap-ido-toggle-prefix ()
(let ((map ido-common-completion-map))
(define-key map [(control ?o)] 'ido-toggle-prefix)
(define-key map [(control ?p)] 'previous-history-element)))
(add-hook 'ido-setup-hook 'remap-ido-toggle-prefix)
Use the clipboard when cutting and pasting and not the primary selection. This is the default.
Uncomment to not use the clipboard.
;; (setq select-enable-clipboard nil)
Uncomment to use the primary selection.
;; (setq select-enable-primary t)
Paste at point position when yanking with the mouse, rather than at click position.
(setq mouse-yank-at-point t)
Type M-+
to join the current line to the previous.
(global-set-key [(meta ?+)] 'delete-indentation)
Type ~M-‘~ to delete horizontal whitespace.
(global-set-key [(meta ?')] 'delete-horizontal-space)
Type M-¡
to delete blank lines.
(global-set-key [(meta ?¡)] 'delete-blank-lines)
Wrap lines at 70 characters.
(setq-default fill-column 70)
Type M-p
and M-n
to move the point backward and forward by paragraph.
(global-set-key [(meta ?n)] 'forward-paragraph)
(global-set-key [(meta ?p)] 'backward-paragraph)
Use two spaces to indicate the end of a sentence.
(setq sentence-end-double-space t)
Use spaces for indentation.
(setq-default indent-tabs-mode nil)
On Unix, use Hunspell to check spelling, with the British English dictionary as the default.
(unless windows-system-p
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "en_GB"))
Type M-x message-mail
to open a new message buffer. This is the
default.
Sender name and address.
(setq user-full-name
(string 69
114 110
101 115 116
32 65 100 114
111 103 117 233))
(setq user-mail-address
(substring "foonr9@posteo.de" 3 nil))
Send mail via an SMTP server. Authentication information is read from
the ~/.authinfo
file.
(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'message-smtpmail-send-it)
(setq smtpmail-default-smtp-server "posteo.de")
(setq smtpmail-smtp-server "posteo.de")
(setq smtpmail-smtp-service 465)
(setq smtpmail-stream-type 'ssl)
Type M-x ps-print-buffer
to generate and print a PostScript image of
the current buffer. With the prefix argument C-u
, save the PostScript
image to a file instead of printing. This is the default.
Print on A4 paper, grayscale, in 10 point Courier.
(setq ps-paper-type 'a4)
(setq ps-print-color-p nil)
(setq ps-print-header nil)
(setq ps-font-family 'Courier)
(setq ps-font-size 10)
Set text mode as the default mode for files and buffers.
(setq-default major-mode 'text-mode)
Open plain text files (*.te?xt
) with Org mode.
(add-to-list 'auto-mode-alist '("\\.te?xt\\'" . org-mode))
Open email messages with message mode.
(add-to-list 'magic-mode-alist '("From:" . message-mode))
Enable auto-filling.
(add-hook 'text-mode-hook 'auto-fill-mode)
Look for Org files in the ~/doc/org
directory.
(setq org-directory (expand-file-name "~/doc/org"))
By default, save notes in the todo.org
file.
(setq org-default-notes-file "todo.org")
Add the Org directory to the list of agenda files. Notice that files
not ending with the extension .org
are ignored.
(with-eval-after-load "org"
(when (listp org-agenda-files)
(add-to-list 'org-agenda-files org-directory)))
Archive subtrees in a separate file.
(setq org-archive-location "%s-archive::")
Read capture and structure templates from the templates.el
file in the
Org directory.
(let ((f (concat (file-name-as-directory org-directory)
"templates.el")))
(when (file-exists-p f)
(load-file f)))
Automatically fold tree when opening a file.
(setq org-startup-folded t)
Do not leave empty lines in collapsed view.
(setq org-cycle-separator-lines 0)
Do not wrap long lines.
(setq org-startup-truncated t)
Do not assume text is indented according to outline structure.
(setq org-adapt-indentation nil)
Do not indent text according to outline structure.
(setq org-startup-indented nil)
Do not add extra indentation in source code blocks.
(setq org-src-preserve-indentation t)
Place footnotes at the end of the current section.
(setq org-footnote-section nil)
Enforce “todo” states dependencies.
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
Uncomment to log changes to “done” states.
;; (setq org-log-done 'time)
Type C-c c
to open a capture template.
(global-set-key [(control ?c) ?c] 'org-capture)
Use syntax highlighting for emphasis and hide mark-up.
(setq org-hide-emphasis-markers t)
Hide leading stars in headings.
(setq org-hide-leading-stars t)
When exporting, do not include a table of contents.
(setq org-export-with-toc nil)
When exporting, do not include author, date, email or creator elements.
(setq org-export-with-author nil)
(setq org-export-with-date nil)
(setq org-export-with-email nil)
(setq org-export-with-creator nil)
Uncomment to enable evaluation of Emacs Lisp and Unix shell blocks.
;; (with-eval-after-load 'org
;; (org-babel-do-load-languages
;; 'org-babel-load-languages
;; '((emacs-lisp . t)
;; (shell . t))))
Use the XeTeX engine.
(setq TeX-engine 'xetex)
On Unix, use xdg-open
to open PDF files.
(defvar TeX-view-program-selection) ; compiler warning
(unless windows-system-p
(with-eval-after-load 'tex
(add-to-list 'TeX-view-program-selection
'(output-pdf "xdg-open"))))
Use light syntax highlighting with normal-sized sub/super-scripts and section headers.
(setq TeX-install-font-lock 'tex-font-setup)
(setq font-latex-fontify-script nil)
(setq font-latex-fontify-sectioning 'color)
Set a4paper
as a default option for document classes.
(setq LaTeX-default-options "a4paper")
Disable symbol completion.
(add-hook 'TeX-mode-hook
(lambda () (setq-local tab-always-indent t)))
Indent new lines.
(setq TeX-newline-function 'newline-and-indent)
Section labels without a prefix.
(setq LaTeX-section-label nil)
Use the equation prefix in multline
and subequations
labels.
(defvar LaTeX-label-alist) ; compiler warning
(with-eval-after-load 'latex
(dolist (elt '(("multline" . LaTeX-equation-label)
("subequations" . LaTeX-equation-label)))
(add-to-list 'LaTeX-label-alist elt)))
Treat comments as ordinary text.
(setq LaTeX-syntactic-comments nil)
Treat comments as LaTeX code in docTeX mode.
(add-hook 'docTeX-mode-hook
(lambda () (setq-local LaTeX-syntactic-comments t)))
Enable RefTex minor mode.
(add-hook 'LaTeX-mode-hook 'reftex-mode)
Uncomment to enable LaTeX-math minor mode.
;; (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
Enable TeX-fold minor mode.
(defvar TeX-fold-env-spec-list) ; compiler warning
(with-eval-after-load 'tex-fold
(dolist (elt '("displaymath"
"equation"
"equation*"
"eqnarray"
"eqnarray*"
"subequations"
"gather"
"gather*"
"align"
"align*"
"alignat"
"alignat*"
"flalign"
"flalign*"
"multline"
"multline*"
"figure"
"table"
"thebibliography"
"titlepage"))
(add-to-list 'TeX-fold-env-spec-list
`(,(format "[%s]" elt) (,elt)))))
(add-hook 'LaTeX-mode-hook 'TeX-fold-mode)
Read-only prompt.
(setq comint-prompt-read-only t)
Type M-p
and M-n
to walk through the history ring, matching the
current input.
(add-hook
'comint-mode-hook
(lambda ()
(let ((map comint-mode-map))
(define-key map [(meta ?p)] 'comint-previous-matching-input-from-input)
(define-key map [(meta ?n)] 'comint-next-matching-input-from-input))))
Insert the original string in the edit buffer when editing an untranslated entry.
(setq po-auto-edit-with-msgid t)
Turn on ruler mode in editing buffers.
(add-hook 'po-subedit-mode-hook 'ruler-mode)
Specify file local variable values for editing buffers using the
po-subedit-
prefix. For example, specifying
;; -*- po-subedit-fill-column: 75 -*-
will result in the variable fill-column
being set to 75 in editing
buffers.
(defvar-local po-subedit-variables-alist nil
"An alist of variable and value pairs to be set in subedit
buffers.")
(defun po-process-file-local-variables ()
"Delete prefixed variables from `file-local-variables-alist'
and put them in `po-subedit-variables-alist' with the prefix
removed."
(let* ((prefix "po-subedit-")
(prefix-length (length prefix))
(prefix-variables)
(nonprefix-variables))
(dolist (elt file-local-variables-alist)
(let ((name (symbol-name (car elt))))
(if (and (string-prefix-p prefix name)
(> (length name) prefix-length))
(push (cons (intern (substring name prefix-length nil))
(cdr elt))
prefix-variables)
(push elt nonprefix-variables))))
(setq po-subedit-variables-alist prefix-variables)
(setq file-local-variables-alist nonprefix-variables)))
(add-hook 'po-mode-hook
(lambda ()
(add-hook 'before-hack-local-variables-hook
'po-process-file-local-variables
nil t)))
(defun po-subedit-set-local-variables ()
"Sets the variables in `po-subedit-variables-alist' to their
corresponding values."
(setq file-local-variables-alist
(buffer-local-value 'po-subedit-variables-alist
(get-buffer (substring (buffer-name) 1 -1))))
(hack-local-variables-apply))
(add-hook 'po-subedit-mode-hook
'po-subedit-set-local-variables)
Type i
or M-x po-ispell-msgstr
to spell-check the entry at point.
To use a dictionary other than the default one, either change the
dictionary globally with M-x ispell-change-dictionary
, or set the
file-local variable po-subedit-ispell-dictionary
.
(eval-when-compile
(load "po-mode")) ; avoid compiler warnings
(with-eval-after-load 'po-mode
(define-key po-mode-map [?i] 'po-ispell-msgstr))
(declare-function po-find-span-of-entry "po-mode")
(declare-function po-edit-msgstr "po-mode")
(declare-function po-subedit-abort "po-mode")
(defun po-ispell-msgstr ()
"Check message string for spelling errors."
(interactive)
(defvar po-entry-type) ; compiler warning
(let ((subedit-buffer (concat "*" (buffer-name) "*"))
pop-to-subedit-buffer)
(po-find-span-of-entry)
(if (eq po-entry-type 'untranslated)
(message "Ignoring untranslated entry.")
(save-window-excursion (po-edit-msgstr))
(when (get-buffer subedit-buffer)
(set-buffer subedit-buffer)
(add-hook 'ispell-update-post-hook
`(lambda ()
(pop-to-buffer ,subedit-buffer)
(setq pop-to-subedit-buffer t))
t t)
(ispell-buffer)
(if pop-to-subedit-buffer
(progn
(pop-to-buffer subedit-buffer)
(message po-subedit-message))
(po-subedit-abort))))))
When checking the spelling of translation strings, ignore format string placeholders and other programing language elements.
(add-hook 'po-subedit-mode-hook
(lambda ()
(make-local-variable 'ispell-skip-region-alist)
;; skip format string placeholders
(add-to-list 'ispell-skip-region-alist
'("%\\([0-9]+$\\)?\\([-+ 0#]\\)?\\([0-9]+|\\*\\)?\\(\\.\\(?:[0-9]\\|\\*\\)\\)?\\([hlLzht]\\|hh\\|ll\\)?[%diufFeEgGxXoscpAn]"))))
(add-hook 'po-subedit-mode-hook
(lambda ()
(make-local-variable 'ispell-skip-region-alist)
;; skip leading/trailing/standalone dashes and command switches
(add-to-list 'ispell-skip-region-alist
'("\\(\\W\\|\\`\\)[-+]\\(\\W\\|[[:alnum:]]+\\|\\'\\)"))))
Wrap lines at 76 characters.
(add-hook 'prog-mode-hook
(lambda () (setq fill-column 76)))
Show matching parentheses.
(add-hook 'prog-mode-hook 'show-paren-mode)
Show white space.
(add-hook 'prog-mode-hook 'whitespace-mode)
Set file permissions when saving executable scripts.
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
Use the GNU Emacs mode (python.el
).
(when (fboundp 'py-shell) (fmakunbound 'py-shell))
(when (fboundp 'doctest-mode) (fmakunbound 'doctest-mode))
(autoload 'python-mode "python" "Python editing mode (python.el)" t)
Try to not require ess-site
, as it slows down start-up considerably.
(autoload 'R-mode "ess-site.el" "Major mode for editing R source." t)
(autoload 'Rd-mode "ess-rd" "Major mode for editing R documentation." t)
(add-to-list 'auto-mode-alist '("\\.[rR]\\'" . R-mode))
(add-to-list 'auto-mode-alist '("\\.[Rr]out" . R-transcript-mode))
(add-to-list 'auto-mode-alist '("\\.Rd\\'" . Rd-mode))
(add-to-list 'interpreter-mode-alist '("Rscript" . R-mode))
(add-to-list 'interpreter-mode-alist '("r" . R-mode))
Do not to save R history.
(setq inferior-R-args "--quiet --no-save")
Type M-p
and M-n
to walk through the history ring, matching the
current input. (We need to set these again, because ESS overrides
comint-mode-map
with its own keymap.)
(defvar inferior-ess-mode-map) ; compiler warning
(with-eval-after-load 'ess
(lambda ()
(let ((map inferior-ess-mode-map))
(define-key map [(meta ?p)] 'comint-previous-matching-input-from-input)
(define-key map [(meta ?n)] 'comint-next-matching-input-from-input))))
Type TAB
to (un)fold Roxygen comments.
(setq ess-roxy-hide-show-p t)
When saving this file, automatically write the Emacs Lisp code blocks
in the Configuration section to the init file init.el
and compile it.
;; Local Variables:
;; eval: (defun write-init-file-and-compile ()
;; (and (y-or-n-p "Write source and byte-compile? ")
;; (org-babel-tangle)
;; (byte-compile-file
;; (replace-regexp-in-string
;; "\\.org\\'" ".el" (buffer-file-name)))))
;; eval: (add-hook 'after-save-hook 'write-init-file-and-compile nil t)
;; End: