Merge remote-tracking branch 'origin/master'

Conflicts:
	.scripts/homeclean
master
Pierre Neidhardt 2014-04-19 17:20:49 +02:00
commit fed7070e83
255 changed files with 3952 additions and 4344 deletions

View File

@ -28,8 +28,9 @@ URxvt.keysym.C-M-Escape: perl:keyboard-select:activate
URxvt.keysym.C-M-v: perl:clipboard:paste
URxvt.keysym.C-M-c: perl:clipboard:paste_escaped
! URxvt.clipboard.pastecmd: xclip -o -selection clipboard -quiet -d locahost:0
URxvt.clipboard.pastecmd: xclip -o -quiet
! URxvt.clipboard.copycmd: xclip -i -selection clipboard
URxvt.clipboard.autocopy: true
URxvt.clipboard.pastecmd: xclip -o -selection primary -quiet
URxvt.clipboard.copycmd: xclip -i -selection primary
!!==============================================================================
!! Font

View File

@ -178,7 +178,7 @@ repeat= .
entry_delete_active=Control d
hints_selector=
hints_selector=
[1]
save_search_field=gs

View File

@ -7,6 +7,7 @@ gm https://maps.google.com/maps?q=%s
gt http://translate.google.com/#en/fr/%s
imdb http://www.imdb.com/find?q=%s&s=all
leo http://dict.leo.org/frde/index_de.html#/search=%s
so http://stackoverflow.com/search?q=%s
torrent http://torrentz.eu/search?f=%s
w http://en.wikipedia.org/wiki/Special:Search?search=%s
wb http://en.wikibooks.org/wiki/Special:Search?search=%s
@ -14,6 +15,8 @@ wbf http://fr.wikibooks.org/wiki/Special:Search?search=%s
wf http://fr.wikipedia.org/wiki/Special:Search?search=%s
wk http://en.wiktionary.org/wiki/Special:Search?search=%s
wkf http://fr.wiktionary.org/wiki/Special:Search?search=%s
wks http://sv.wiktionary.org/wiki/Special:Search?search=%s
wine http://www.winehq.org/search/?cx=partner-pub-0971840239976722:w9sqbcsxtyf&cof=FORID:10&ie=UTF-8&q=%s
wr http://www.wordreference.com/enfr/%s
ws http://sv.wikipedia.org/wiki/Special:Search?search=%s
yt http://www.youtube.com/results?search_query=%s

View File

@ -140,7 +140,7 @@ scroll-step=0.00
close-last-tab-policy=clear
foreground-color=#ffffff
message-delay=2
scheme-handler=dwb-scheme
scheme-handler=
default-font-size=12
enable-offline-web-application-cache=true
hints-key-lock=250

View File

@ -4,25 +4,25 @@ extensions.load("adblock_subscriptions", {
//<adblock_subscriptions___CONFIG
// Shortcut to subscribe to a filterlist
scSubscribe : null,
scSubscribe : null,
// Command to subscribe to a filterlist
cmdSubscribe : "adblock_subscribe",
cmdSubscribe : "adblock_subscribe",
// Shortcut to unsubscribe from a filterlist
scUnsubscribe : null,
scUnsubscribe : null,
// Command to unsubscribe from a filterlist
cmdUnsubscribe : "adblock_unsubscribe",
// Shortcut to update subscriptions and reload filter rules
// Note that dwb will also update all subscriptions on startup
scUpdate : null,
scUpdate : null,
// Command to update subscriptions and reload filter rules
// Note that dwb will also update all subscriptions on startup
cmdUpdate : "adblock_update",
cmdUpdate : "adblock_update",
// Path to the filterlist directory, will be created if it doesn't exist.
// Path to the filterlist directory, will be created if it doesn't exist.
filterListDir : "~/.config/dwb/adblock_lists"
//>adblock_subscriptions___CONFIG
});
@ -36,13 +36,13 @@ forwardBind : "]]",
// Shortcut for navigating to the previous page
backBind : "[[",
// Go up one directory, e.g. from http://www.example.com/foo/bar to
// Go up one directory, e.g. from http://www.example.com/foo/bar to
// http://www.example.com/foo
updirBind : "gu",
updirBind : "gu",
// Go to top directory, e.g. from http://www.example.com/foo/bar to
// Go to top directory, e.g. from http://www.example.com/foo/bar to
// http://www.example.com
topdirBind : "gU",
topdirBind : "gU",
// Patterns to match against when searching for "next"-links
nextPatterns : "next,more,>,\u2192,\xbb,\u226b,>>",
@ -58,14 +58,14 @@ previousPatterns : "prev,previous,back,<,\u2190,\xab,\u226a,<<"
extensions.load("autoquvi", {
//<autoquvi___CONFIG
// The quvi command
quvi : "quvi",
quvi : "quvi",
// External player command
player : "mplayer %u",
player : "mplayer %u",
// Whether to automatically play videos when quvi find a playable
// video
autoPlay : true,
autoPlay : true,
// Whether to choose the quality before quvi starts
chooseQuality : true,
@ -73,10 +73,81 @@ extensions.load("autoquvi", {
// A shortcut that spawns quvi for the current website
shortcut : "",
// A command that spawns quvi for the current website
// A command that spawns quvi for the current website
command : "autoquvi"
//>autoquvi___CONFIG
});
autoquvi___DISABLED>*/
//>autoquvi___SCRIPT
//<downloadhandler___SCRIPT
extensions.load("downloadhandler", {
//<downloadhandler___CONFIG
handler : [
// Each handler must have 2 or 3 properties:
//
// command : command to execute, must contain %f which will be replaced with
// the filepath, this property is mandatory
//
// extension : a filename extension, optional
//
// mimeType : a mimetype, optional
//
// { command : "xpdf %f", mimeType : "application/pdf" }
// { command : "xdvi %f", extension : "dvi" }
]
//>downloadhandler___CONFIG
});
//>downloadhandler___SCRIPT
//<contenthandler___SCRIPT
extensions.load("contenthandler", {
//<contenthandler___CONFIG
// The handler can either be a string or a function, if it is a string
// %u will be replaced with the uri of the request, if the handler is a
// function the first parameter of the function will be the uri and the
// function must return the command to execute.
// Handle requests based on filename extension
extension : {
// Note that the extension handler does not always work (e.g. on
// torrenthound). As a workaround transmission can be configured to watch
// for the download path.
"torrent" : "trc -a '%u'"
// "pdf" : "xterm -e 'wget %u --directory-prefix=~/mypdfs'"
},
// Handle requests based on URI scheme
uriScheme : {
// Note: does not work with urxvt.
ftp : function(uri) {
if (uri[uri.length-1] == "/")
return "xterm -e 'ncftp " + uri + "'";
else
return "xterm -e 'ncftpget " + uri + "'";
},
// We need to use 'sh -c' since we need to use a pipe so that xclip can
// read from stdin
mailto : function(uri) {
uri=uri.replace(/mailto:/, "")
uri=uri.replace(/\?/, " ")
return "sh -c ' echo " + uri + " | xclip -i'";
},
// 'trc' is a wrapper script that will launch transmission-daemon if not
// already started.
// magnet: "transmission-remote -a '%u'"
magnet: "trc -a '%u'"
},
// Handle requests based on MIME type
mimeType : {
// "application/pdf" : "xterm -e 'wget %u --directory-prefix=~/mypdfs'"
}
//>contenthandler___CONFIG
});
//>contenthandler___SCRIPT

BIN
.config/mps-youtube/config Normal file

Binary file not shown.

View File

@ -1,11 +0,0 @@
## Default script.
script="vorbis"
## Root of all output files.
library="$HOME/musics"
library_ext="/media/backup2/Musics"
## Terminal output. Turn it off when not redirecting to stdout.
use_colors=true
use_formatting=true

21
.config/musish/musishrc Normal file
View File

@ -0,0 +1,21 @@
## Default script.
script="vorbis"
## Root of all output files.
library="$HOME/musics"
library_ext="/media/backup2/Musics"
library_temp="$HOME/lib"
## Terminal output. Turn it off when not redirecting to stdout.
use_colors=true
use_formatting=true
## Replace chars: same as default with [] -> ()
tagsed="s/[´]/'/g; s/]/)/g; s/\[/(/g; s| *[/|\\:] *| - |g"
## French
constants="$constants un une de du le la les et mais pour ni ou à a où contre entre chez dans sur que qui "
## German
constants="$constants der die das den dem des ein eine einen eines einer wo an am in bei aus mit nach seit von zu vom zur zum durch für gegen ohne um "
## Music
constants="$constants d'Acide JBX "

View File

@ -0,0 +1,44 @@
#!/bin/sh
## X-Ray Dog.
artist="X-Ray Dog"
## Albums actually have years, but is it relevent since they have a code?
date=""
## Genre could be Soundtrack, or Trailer Music. We choose "" for now.
genre=""
## Extract album code, assuming parent folder is "XRCD## - $album".
XRCD="${FILENAME%/*}"
XRCD="${XRCD##*/}"
XRCD="${XRCD%% - *}"
## Append the album code to the constants array, other it will be capitalized.
constants="$constants $XRCD "
if [ -z "${album%%XRCD *}" ]; then
## Change "XRCD - ## - ..." -> "XRCD## - "
album="${album#XRCD}"
album="${album##*[0-9] }"
album="${album#-}"
album="$XRCD - $album"
elif [ -n "${album%%XRCD*}" ]; then
album="$XRCD - $album"
fi
if [ -z "${title}" ]; then
title="${FILENAME##*/}"
title="${title%.*}"
# title="$(echo "$title" | sed 's/X-Ray Dog//')"
title="$(echo "$title" | sed 's/X-Ray Dog\( \?- \?\)\?//')"
fi
if [ -z "${track}" ]; then
track="${title% *}"
title="${title#* }"
fi
subscript="$(findscript vorbis)"
if [ ! -f "$subscript" ]; then
_error "Subscript '$subscript' not found."
else
. "$subscript"
fi

View File

@ -0,0 +1,68 @@
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/home/peter/temp",
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 2,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/home/peter/Downloads",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"message-level": 2,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 200,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": true,
"preallocation": 1,
"prefetch-enabled": 1,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-password": "{59ff5bb6c897a6eb0a5a1be27f2ba73c77f7a49843vQktLP",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "",
"rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": true,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": true,
"umask": 18,
"upload-slots-per-torrent": 14,
"utp-enabled": true,
"watch-dir": "/home/peter/temp",
"watch-dir-enabled": true
}

View File

@ -5,52 +5,104 @@
(define-abbrev-table 'awk-mode-abbrev-table '())
(define-abbrev-table 'bibtex-mode-abbrev-table '())
(define-abbrev-table 'c++-mode-abbrev-table '())
(define-abbrev-table 'c-mode-abbrev-table '())
(define-abbrev-table 'calendar-mode-abbrev-table '())
(define-abbrev-table 'comint-mode-abbrev-table '())
(define-abbrev-table 'completion-list-mode-abbrev-table '())
(define-abbrev-table 'conf-colon-mode-abbrev-table '())
(define-abbrev-table 'conf-javaprop-mode-abbrev-table '())
(define-abbrev-table 'conf-ppd-mode-abbrev-table '())
(define-abbrev-table 'conf-space-mode-abbrev-table '())
(define-abbrev-table 'conf-unix-mode-abbrev-table '())
(define-abbrev-table 'conf-windows-mode-abbrev-table '())
(define-abbrev-table 'conf-xdefaults-mode-abbrev-table '())
(define-abbrev-table 'docTeX-mode-abbrev-table '())
(define-abbrev-table 'doctex-mode-abbrev-table '())
(define-abbrev-table 'emacs-lisp-byte-code-mode-abbrev-table '())
(define-abbrev-table 'emacs-lisp-mode-abbrev-table '())
(define-abbrev-table 'fundamental-mode-abbrev-table '())
(define-abbrev-table 'gfm-mode-abbrev-table '())
(define-abbrev-table 'global-abbrev-table '())
(define-abbrev-table 'help-mode-abbrev-table '())
(define-abbrev-table 'html-mode-abbrev-table '())
(define-abbrev-table 'idl-mode-abbrev-table '())
(define-abbrev-table 'java-mode-abbrev-table '())
(define-abbrev-table 'latex-mode-abbrev-table '())
(define-abbrev-table 'lisp-mode-abbrev-table '())
(define-abbrev-table 'lua-mode-abbrev-table '())
(define-abbrev-table 'markdown-mode-abbrev-table '())
(define-abbrev-table 'objc-mode-abbrev-table '())
(define-abbrev-table 'occur-edit-mode-abbrev-table '())
(define-abbrev-table 'occur-mode-abbrev-table '())
(define-abbrev-table 'org-mode-abbrev-table '())
(define-abbrev-table 'outline-mode-abbrev-table '())
(define-abbrev-table 'perl-mode-abbrev-table '())
(define-abbrev-table 'pike-mode-abbrev-table '())
(define-abbrev-table 'plain-tex-mode-abbrev-table '())
(define-abbrev-table 'po-mode-abbrev-table '())
(define-abbrev-table 'process-menu-mode-abbrev-table '())
(define-abbrev-table 'prog-mode-abbrev-table '())
(define-abbrev-table 'select-tags-table-mode-abbrev-table '())
(define-abbrev-table 'sgml-mode-abbrev-table '())
(define-abbrev-table 'sh-mode-abbrev-table '())
(define-abbrev-table 'shell-mode-abbrev-table '())
(define-abbrev-table 'slitex-mode-abbrev-table '())
(define-abbrev-table 'snippet-mode-abbrev-table '())
(define-abbrev-table 'special-mode-abbrev-table '())
(define-abbrev-table 'tabulated-list-mode-abbrev-table '())
(define-abbrev-table 'tex-mode-abbrev-table '())
(define-abbrev-table 'tex-shell-abbrev-table '())
(define-abbrev-table 'text-mode-abbrev-table
'(
("ac" "avec" nil 0)
@ -67,7 +119,7 @@
("atm" "at the moment" nil 1)
("autom" "automatique" nil 2)
("automt" "automatiquement" nil 2)
("bcp" "beaucoup" nil 2)
("bcp" "beaucoup" nil 3)
("biblio" "bibliothèque" nil 1)
("biblios" "bibliothèques" nil 1)
("btw" "by the way" nil 1)
@ -82,7 +134,7 @@
("cmt" "comment" nil 1)
("coeur" "cœur" nil 1)
("coeurs" "cœurs" nil 1)
("config" "configuration" nil 1)
("config" "configuration" nil 2)
("configs" "configurations" nil 1)
("cpd" "cependant" nil 2)
("cvg" "converge" nil 1)
@ -173,7 +225,6 @@
("pcq" "parce que" nil 3)
("pdt" "pendant" nil 2)
("pe" "peut-être" nil 2)
("pe" "peut-être" nil 2)
("pgrm" "program" nil 1)
("pgrms" "programs" nil 1)
("plsu" "plus" nil 3)
@ -219,6 +270,8 @@
("ê" "être" nil 1)
))
(define-abbrev-table 'vc-git-log-edit-mode-abbrev-table '())
(define-abbrev-table 'vc-git-log-view-mode-abbrev-table '())
(define-abbrev-table 'vc-svn-log-view-mode-abbrev-table '())

View File

@ -2,31 +2,494 @@
;; FUNCTIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun unfill-paragraph ()
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
(defun add-hook-and-eval (hook function)
"Add FUNCTION to HOOK and evaluate it.
This can be useful when called from a hooked function to make
sure it gets executed."
(add-hook hook function)
(funcall function))
(defun unfill-region ()
(defun calc-eval-line ()
"Append calc expression to end of line after an ' = ' separtor.
Regular math expression can be computed with calc."
(interactive)
(let ((fill-column (point-max)))
(fill-region (region-beginning) (region-end) nil)))
(end-of-line)
(insert " = " (calc-eval (buffer-substring-no-properties
(line-beginning-position) (line-end-position)))))
(defun sort-lines-unique ()
"Remove duplicate lines using shell command `sort -u'"
(defun call-process-to-string (program &rest args)
"Call PROGRAM with ARGS and return output."
(with-output-to-string
(with-current-buffer
standard-output
(apply 'call-process program nil t nil args))))
(defun comment-or-uncomment-current-line-or-region ()
"Comments or uncomments current current line or whole lines in region."
(interactive)
(shell-command-on-region (point) (mark) "sort -u" (buffer-name) t))
(save-excursion
(let (min max)
(if (region-active-p)
(setq min (region-beginning) max (region-end))
(setq min (point) max (point)))
(comment-or-uncomment-region
(progn (goto-char min) (line-beginning-position))
(progn (goto-char max) (line-end-position))))))
(define-key my-keys-minor-mode-map "\M-;" 'comment-or-uncomment-current-line-or-region)
(defun dtwi () "Delete trailing whitespaces interactively."
(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-custom (&optional runhooks)
"Call `recompile'.
If RUNHOOKS is non-nil (or with universal argument), run hooks in
`compilation-before-hook', then `recompile', then
`compilation-after-hook'."
(interactive "P")
(when (or runhooks (string= compile-command "make -k ")) (run-hooks 'compilation-before-hook))
(recompile)
(when (or runhooks (string= compile-command "make -k ")) (run-hooks 'compilation-after-hook)))
(defun count-occurences (regex string)
"Return number of times regex occurs in string.
If you want to operate on buffer, use `how-many' instead."
(let ((start 0) (matches 0))
(while (string-match regex string start)
(setq start (match-end 0))
(setq matches (1+ matches)))
matches))
(defun count-percents (string)
"Return count of 'printf' conversion specifications.
Those specifications are introduced by a percent
sign (%). Escaped percent signs (%%) are skipped."
(let ((start 0) (matches 0))
(while (string-match "%." string start)
(unless (string= (match-string 0 string) "%%")
(setq matches (1+ matches)))
(setq start (match-end 0)))
matches))
(defun dtwi ()
"Delete trailing whitespaces interactively."
(interactive)
(query-replace-regexp " +
" "
"))
(defun duplicate (arg)
"Duplicate the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg
end
(origin (point))
(auto-fill-p (symbol-value 'auto-fill-function)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
(exchange-point-and-mark))
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(auto-fill-mode -1)
(dotimes (i arg)
(goto-char end)
(newline)
(insert region)
(setq end (point)))
(if auto-fill-p (auto-fill-mode))
(goto-char (+ origin (* (length region) arg) arg)))))
(define-key my-keys-minor-mode-map (kbd "C-x M-d") 'duplicate)
(defun escape-region (&optional regex to-string)
"Escape double-quotes and backslashes.
You can control the regex replacement with the two optional
parameters."
(interactive)
(unless regex (setq regex "\\([\"\\\\]\\)"))
(unless to-string (setq to-string "\\\\\\1"))
(save-excursion
(while (re-search-forward
regex
(if (not mark-active)
(point-max)
(when (> (point) (mark)) (exchange-point-and-mark))
(mark))
t)
(replace-match to-string))))
(defun eval-and-replace ()
"Replace the last sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
;; Fix forward-page. Previously, when the point was at the end of the page,
;; going forward would skip 1 page. Changed:
;;
;; (if (bolp) (forward-char 1))
;;
;; to
;;
;; (if (string= page-delimiter "")
;;
;; I do not know why the (bolp) condition was used since it does not match the
;; above comment. TODO: report this fix!
(defun forward-page (&optional count)
"Move forward to page boundary. With arg, repeat, or go back if negative.
A page boundary is any line whose beginning matches the regexp
`page-delimiter'."
(interactive "p")
(or count (setq count 1))
(while (and (> count 0) (not (eobp)))
;; In case the page-delimiter matches the null string,
;; don't find a match without moving.
(if (string= page-delimiter "") (forward-char 1))
(if (re-search-forward page-delimiter nil t)
nil
(goto-char (point-max)))
(setq count (1- count)))
(while (and (< count 0) (not (bobp)))
;; In case the page-delimiter matches the null string,
;; don't find a match without moving.
(and (save-excursion (re-search-backward page-delimiter nil t))
(= (match-end 0) (point))
(goto-char (match-beginning 0)))
(forward-char -1)
(if (re-search-backward page-delimiter nil t)
;; We found one--move to the end of it.
(goto-char (match-end 0))
;; We found nothing--go to beg of buffer.
(goto-char (point-min)))
(setq count (1+ count))))
(defun get-closest-pathname (&optional file)
"Get pathname of the first instance of FILE towards root.
If FILE is unspecified, look for 'Makefile'. If it does not find
FILE, then it shall return the name of FILE in the current
directory, suitable for creation. This may not do the correct
thing in presence of links."
(let ((current-dir default-directory) (looping t) (makefile (or file "Makefile")))
(while (progn
(if (file-exists-p (expand-file-name makefile current-dir))
(setq looping nil)
(setq current-dir (expand-file-name ".." current-dir)))
(and looping (not (equal current-dir "/")))))
(if (equal current-dir "/") nil (expand-file-name makefile current-dir))))
(defun insert-and-indent (text)
"Insert indented TEXT at point."
(interactive "s Text: ")
(let ((oldpoint (point)))
(insert text)
(indent-region oldpoint (point))
(newline-and-indent)))
(defun insert-file-name (filename &optional args)
"Insert name of file FILENAME into buffer after point.
Prefixed with \\[universal-argument], expand the file name to its
fully canocalized path. See `expand-file-name'.
Prefixed with \\[negative-argument], use relative path to file
name from current directory, `default-directory'. See
`file-relative-name'.
The default with no prefix is to insert the file name exactly as
it appears in the minibuffer prompt."
;; Based on insert-file in Emacs -- ashawley 20080926
(interactive "*fInsert file name: \nP")
(cond ((eq '- args)
(insert (file-relative-name filename)))
((not (null args))
(insert (expand-file-name filename)))
(t
(insert filename))))
(define-key my-keys-minor-mode-map "\C-x\M-f" 'insert-file-name)
(defun kill-all-buffers ()
"Kill all buffers, leaving *scratch* only."
(interactive)
(mapc
(lambda (x)
(kill-buffer x))
(buffer-list))
(delete-other-windows))
(defun map-on-pair (function sequence)
"Map a function taking two arguments on a sequence of pairs."
(mapcar (lambda (p) (funcall function (car p) (cadr p))) sequence ))
(defun load-external (ext feature &optional mode default)
"Add the EXT regex to `auto-mode-alist' such that it loads the
associated symbol FEATURE. If FEATURE has not the same name as
the mode, you should provide the real mode name in symbol MODE.
If MODE is nil or unspecified, FEATURE is used as the mode name.
We call `autoload' to make the mode accessible interactively. We
need `require' to check if feature is loadable. It allows us to
fallback to the mode provided in symbol DEFAULT."
(let ((local-mode (if mode mode feature)))
(autoload local-mode (symbol-name feature) nil t)
(add-to-list
'auto-mode-alist
(cons ext `(lambda ()
(if (require ',feature nil t)
(,local-mode)
,(if (null default)
`(warn "Could not load %s, fallback to %s"
(symbol-name ',feature) (symbol-name ',default-major-mode))
`(progn
(,default)
(warn "Could not load %s, fallback to %s"
(symbol-name ',feature) (symbol-name ',default))))))))))
(defun mark-word-from-beginning (&optional arg allow-extend)
"Set the point at the beginning of the word and call `mark-word'."
(interactive "P\np")
(cond ((and allow-extend
(or (and (eq last-command this-command) (mark t))
(region-active-p)))
(mark-word arg allow-extend))
(t
;; The next line makes sure the word at point gets selected if point is
;; on the first letter. We need to ignore error if point is at EOF.
(ignore-errors (forward-char))
(backward-word)
(mark-word arg allow-extend))))
(define-key my-keys-minor-mode-map (kbd "M-@") 'mark-word-from-beginning)
(defun move-border-left (arg)
"Move window border in a natural manner.
If this is a window with its right edge being the edge of the
screen, enlarge the window horizontally. If this is a window with
its left edge being the edge of the screen, shrink the window
horizontally. Otherwise, default to enlarging horizontally.\n
Enlarge/Shrink by ARG columns, or 5 if arg is nil."
(interactive "P")
(if (= (count-windows) 2)
(move-border-left-or-right arg t)))
(define-key my-keys-minor-mode-map (kbd "M-(") 'move-border-left)
(defun move-border-left-or-right (arg dir)
"Wrapper around move-border-left and move-border-right.
If DIR is t, then move left, otherwise move right."
(interactive)
(if (null arg) (setq arg 5))
(let ((left-edge (nth 0 (window-edges))))
(if (xor (= left-edge 0) dir)
(shrink-window arg t)
(enlarge-window arg t))))
(defun move-border-right (arg)
"See `move-border-left'."
(interactive "P")
(if (= (count-windows) 2)
(move-border-left-or-right arg nil)))
(define-key my-keys-minor-mode-map (kbd "M-)") 'move-border-right)
(defun page-count ()
"Return page count.
Requires `count-occurences'."
(save-restriction
(widen)
(save-excursion
(+ 1 (how-many
page-delimiter 1 (point-max))))))
(defun page-number ()
"Reurn page number."
(save-restriction
(widen)
(save-excursion
(let ((count 1)
(opoint (point)))
(goto-char (point-min))
(while (re-search-forward page-delimiter opoint t)
(if (= (match-beginning 0) (match-end 0))
(forward-char 1))
(setq count (1+ count)))
count)
)))
(defun page-number-mode (activate)
"Display of page number in mode line.
If ACTIVATE is non-nil, enable, disable otherwise. Interactively,
activate unless called with universal argument.\n\nThis adds
page-number/page-count to mode line. It will only display if
there is more than one page. A page is delimited by
page-delimiter.\n
WARNING: this may slow down editing on big files."
(interactive (list (not (equal current-prefix-arg '(4)))))
(setq mode-line-format
`("%e"
mode-line-front-space
mode-line-mule-info
mode-line-client
mode-line-modified
mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
" "
mode-line-position
,(when activate '(:eval (when (> (page-count) 1) (format "%d/%d" (page-number) (page-count)))))
(vc-mode vc-mode)
" "
mode-line-modes
mode-line-misc-info
mode-line-end-spaces)))
(defun pos-at-line (arg)
"Return the position at beginning of line."
(save-excursion
(goto-line arg)
(beginning-of-line)
(point)))
(defun rename-buffer-and-file ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(cond ((get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name))
(t
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
(define-key my-keys-minor-mode-map (kbd "C-x w") 'rename-buffer-and-file)
(defun sanitize ()
"Untabifies, indents and deletes trailing whitespace.
Works on buffer or region."
(interactive)
(save-excursion
(unless (region-active-p)
(mark-whole-buffer))
(untabify (region-beginning) (region-end))
(indent-region (region-beginning) (region-end))
(save-restriction
(narrow-to-region (region-beginning) (region-end))
(delete-trailing-whitespace))))
(defun shell-last-command ()
"Run last shell command."
(interactive)
(let ((last (car shell-command-history)))
(if last
(shell-command last)
(error "Shell command history is empty"))))
(define-key my-keys-minor-mode-map (kbd "C-M-!") 'shell-last-command)
(defun skeleton-make-markers ()
"Save last skeleton markers in a list.
Hook function for skeletons."
(while skeleton-markers
(set-marker (pop skeleton-markers) nil))
(setq skeleton-markers
(mapcar 'copy-marker (reverse skeleton-positions))))
(defvar skeleton-markers nil
"Markers for locations saved in skeleton-positions.")
(defun skeleton-next-position (&optional reverse)
"Skeleton movements through placeholders."
(interactive "P")
(let ((positions (mapcar 'marker-position skeleton-markers))
(comp (if reverse '< '<=))
pos prev)
(when positions
(setq pos (pop positions))
(while (and pos (funcall comp pos (point)))
(setq prev pos)
(setq pos (pop positions)))
(cond
((and reverse prev) (goto-char prev))
(reverse (goto-char (car (last skeleton-markers))))
(pos (goto-char pos))
(t (goto-char (car skeleton-markers)))))))
(defun sort-lines-unique ()
"Remove duplicate lines using shell command `sort -u'."
(interactive)
(call-process-region (point) (mark) "sort" t t nil "-u"))
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((/= (count-windows) 2)
(message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1))))
(other-window 1))
(define-key my-keys-minor-mode-map (kbd "C-x M-s") 'swap-windows)
(defun toggle-indent-tabs ()
"Indent with tabs or spaces."
(interactive)
(if indent-tabs-mode
(progn
(message "Indent using spaces")
(setq indent-tabs-mode nil))
(message "Indent using tabs")
(setq indent-tabs-mode t)))
(define-key my-keys-minor-mode-map (kbd "C-x M-i") 'toggle-indent-tabs)
(defun toggle-trailing-whitespace ()
"Show trailing whitespace or not."
(interactive)
(if show-trailing-whitespace
(setq show-trailing-whitespace nil)
(setq show-trailing-whitespace t)))
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not.
Run it in each window you want to 'freeze', i.e. prevent Emacs
from acting on it."
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
(current-buffer)))
(define-key my-keys-minor-mode-map [pause] 'toggle-window-dedicated)
(defun toggle-window-split ()
"Vertical split shows more of each line, horizontal split shows
more lines. This code toggles between them. It only works for
frames with exactly two windows."
"Switch between vertical and horizontal split.
It only works for frames with exactly two windows."
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
@ -50,278 +513,37 @@ frames with exactly two windows."
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(define-key my-keys-minor-mode-map [(control x) (|)] 'toggle-window-split)
(define-key my-keys-minor-mode-map [(control c) (|)] 'toggle-window-split)
(defun duplicate (arg)
"Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg
end
(origin (point))
(auto-fill-p (symbol-value 'auto-fill-function)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
(exchange-point-and-mark))
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(auto-fill-mode -1)
(dotimes (i arg)
(goto-char end)
(newline)
(insert region)
(setq end (point)))
(if auto-fill-p (auto-fill-mode))
(goto-char (+ origin (* (length region) arg) arg)))))
(define-key my-keys-minor-mode-map (kbd "C-c C-d") 'duplicate)
(defun comment-or-uncomment-current-line-or-region ()
"Comments or uncomments current current line or whole lines in region."
(defun toggle-word-delim ()
"Make underscore part of the word syntax or not.
This does not interfere with `subword-mode'."
(interactive)
(save-excursion
(let (min max)
(if (region-active-p)
(setq min (region-beginning) max (region-end))
(setq min (point) max (point)))
(comment-or-uncomment-region
(progn (goto-char min) (line-beginning-position))
(progn (goto-char max) (line-end-position))))))
(if (equal (char-syntax ?_) "_")
(progn
(modify-syntax-entry ?_ "w")
(message "_ is a not word delimiter"))
(modify-syntax-entry ?_ "_")
(message "_ is a word delimiter")))
(define-key my-keys-minor-mode-map "\M-;" 'comment-or-uncomment-current-line-or-region)
(defun unfill-paragraph ()
"Paragraph at point is unwrapped on one single line."
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
(defun unfill-region ()
"Unfill all paragraphs found in current region.
Each paragraph stand on its line."
(interactive)
(let ((fill-column (point-max)))
(fill-region (region-beginning) (region-end) nil)))
(defun xor (b1 b2)
"Exclusive or of its two arguments."
(or (and b1 b2)
(and (not b1) (not b2))))
(defun move-border-left-or-right (arg dir)
"General function covering move-border-left and
move-border-right. If DIR is t, then move left, otherwise move
right."
(interactive)
(if (null arg) (setq arg 5))
(let ((left-edge (nth 0 (window-edges))))
(if (xor (= left-edge 0) dir)
(shrink-window arg t)
(enlarge-window arg t))))
(defun move-border-left (arg)
"If this is a window with its right edge being the edge of the
screen, enlarge the window horizontally. If this is a window with
its left edge being the edge of the screen, shrink the window
horizontally. Otherwise, default to enlarging horizontally.
Enlarge/Shrink by ARG columns, or 5 if arg is nil."
(interactive "P")
(if (= (count-windows) 2)
(move-border-left-or-right arg t)))
(defun move-border-right (arg)
"If this is a window with its right edge being the edge of the
screen, shrink the window horizontally. If this is a window with
its left edge being the edge of the screen, enlarge the window
horizontally. Otherwise, default to shrinking horizontally.
Enlarge/Shrink by ARG columns, or 5 if arg is nil."
(interactive "P")
(if (= (count-windows) 2)
(move-border-left-or-right arg nil)))
(define-key my-keys-minor-mode-map (kbd "M-(") 'move-border-left)
(define-key my-keys-minor-mode-map (kbd "M-)") 'move-border-right)
(defun eval-and-replace ()
"Replace the last sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((/= (count-windows) 2)
(message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1))))
(other-window 1))
(define-key my-keys-minor-mode-map (kbd "C-c s") 'swap-windows)
(defun rename-buffer-and-file ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(cond ((get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name))
(t
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name))))))))
(define-key my-keys-minor-mode-map (kbd "C-x C-w") 'rename-buffer-and-file)
(defun kill-all-buffers ()
"Kill all buffers, leaving *scratch* only."
(interactive)
(mapc
(lambda (x)
(kill-buffer x))
(buffer-list))
(delete-other-windows))
(defun sanitize ()
"Untabifies, indents and deletes trailing whitespace from buffer or region."
(interactive)
(save-excursion
(unless (region-active-p)
(mark-whole-buffer))
(untabify (region-beginning) (region-end))
(indent-region (region-beginning) (region-end))
(save-restriction
(narrow-to-region (region-beginning) (region-end))
(delete-trailing-whitespace))))
(defun shell-last-command ()
"Run last shell command."
(interactive)
(let ((last (car shell-command-history)))
(if last
(shell-command last)
(message "Shell command history is empty."))))
(define-key my-keys-minor-mode-map (kbd "C-M-!") 'shell-last-command)
(defun map-on-pair (function sequence)
"Map a function taking two arguments on a sequence of pairs."
(mapcar (lambda (p) (funcall function (car p) (cadr p))) sequence ))
(defun mark-word (&optional arg allow-extend)
"Set mark ARG words away from point.
The place mark goes is the same place \\[forward-word] would move
to with the same argument. Interactively, if this command is
repeated or (in Transient Mark mode) if the mark is active, it
marks the next ARG words after the ones already marked.
This overloads the vanilla function to mark words from the
beginning."
(interactive "P\np")
(cond ((and allow-extend
(or (and (eq last-command this-command) (mark t))
(region-active-p)))
(setq arg (if arg (prefix-numeric-value arg)
(if (< (mark) (point)) -1 1)))
(set-mark
(save-excursion
(goto-char (mark))
(forward-word arg)
(point))))
(t
;; The next line makes sure the word at point gets selected if point is
;; on the first letter. We need to ignore error if point is at EOF.
(ignore-errors (forward-char))
(backward-word)
(push-mark
(save-excursion
(forward-word (prefix-numeric-value arg))
(point))
nil t))))
(setq translate-lang-input "")
(setq translate-lang-output "en")
(setq translate-lang-p nil)
(defun translate-set-language ()
"Set input/output languages for current buffer. Leave input
empty for auto-detect. Empty output defaults to English."
(interactive)
(set (make-local-variable 'translate-lang-input)
(read-from-minibuffer "Input language: "))
(let ((out (read-from-minibuffer "Output language: ")))
(set (make-local-variable 'translate-lang-output)
(if (string-match "^ *$" out) "en" out))))
(defun translate ()
"Replace current region with its translation."
(interactive)
(unless translate-lang-p
(translate-set-language)
(set (make-local-variable 'translate-lang-p) t))
(shell-command-on-region
(point) (mark)
(concat "translate "
(unless (string= translate-lang-input "")
(concat "-i " translate-lang-input))
" " translate-lang-output) nil t))
(defun translate-line-by-line ()
"Translate lines in region or current line if there is no
region. Output result at the end after an ' = ' separtor."
(interactive)
(unless translate-lang-p
(translate-set-language)
(set (make-local-variable 'translate-lang-p) t))
(let ((line)
(cmd (concat "translate "
(unless (string= translate-lang-input "")
(concat "-i " translate-lang-input))
" " translate-lang-output))
(beg (line-number-at-pos (point)))
(end (line-number-at-pos (if mark-active (mark) (point)))))
;; Mark is assumed to specify the end. If it not not the case, we switch
;; the values.
(when (> beg end)
(setq beg (line-number-at-pos (mark)))
(setq end (line-number-at-pos (point))))
(save-excursion
;; forward-line will remain on the same line if EOF has been reached. Need
;; to check for it.
(while (<= beg end)
(goto-line beg)
(setq line (buffer-substring-no-properties
(line-beginning-position) (line-end-position)))
(unless (string-match "^ *$" line)
(end-of-line)
(insert " = " (shell-command-to-string
(concat cmd " '" line "'")))
;; Shell commands usually outputs an EOL. We should remove it.
(delete-char -1))
(setq beg (1+ beg))))))
(defun pos-at-line (arg)
"Return the position at beginning of line."
(save-excursion
(goto-line arg)
(beginning-of-line)
(point)))
(defun toggle-trailing-whitespace ()
(interactive)
(if show-trailing-whitespace
(setq show-trailing-whitespace nil)
(setq show-trailing-whitespace t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'functions)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,53 +0,0 @@
;; -*- mode:emacs-lisp -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs config
;; 2013-06-12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar my-keys-minor-mode-map (make-keymap)
"Keymap for my-keys-minor-mode. See its docstring for more
details.")
(define-minor-mode my-keys-minor-mode
"A minor mode so that all bindings assingned on the
my-keys-minor-mode-map override undesired major modes
bindings. We use a minor mode to override global keys. This is
also rather useful to list all personal global bindings: just
rgrep `my-keys-minor-mode-map' over `~/.emacs.d'.
Example: to assign some-function to C-i, use
(define-key my-keys-minor-mode-map (kbd \"C-i\") 'some-function)"
t " my-keys" 'my-keys-minor-mode-map)
(add-hook 'minibuffer-setup-hook (lambda () (my-keys-minor-mode 0) ) )
(defvar emacs-cache-folder "~/.cache/emacs/"
"Cache folder is everything we do not want to track along with
the configuration files.")
(if (not (file-directory-p emacs-cache-folder))
(make-directory emacs-cache-folder t))
;; Local plugin folder for quick install. All files in this folder will be
;; accessible to Emacs config.
(add-to-list 'load-path "~/.emacs.d/plugins")
(load "~/.emacs.d/functions" nil t)
(load "~/.emacs.d/main" nil t)
(load "~/.emacs.d/mode-cc.el" nil t)
(load "~/.emacs.d/mode-dot.el" nil t)
(load "~/.emacs.d/mode-mediawiki.el" nil t)
(load "~/.emacs.d/mode-python.el" nil t)
(load "~/.emacs.d/mode-shell.el" nil t)
(load "~/.emacs.d/mode-tex.el" nil t)
(load "~/.emacs.d/mode-texinfo.el" nil t)
(load "~/.emacs.d/personal" nil t)
;; (load "~/.emacs.d/snippets.el" nil t)
(load "~/.emacs.d/theme" nil t)
;; We need to put it at the end to make sure it doesn't get overriden by other
;; minor modes.
(my-keys-minor-mode 1)
;; End of file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,8 +1,7 @@
;; -*- mode:emacs-lisp -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs config
;; 2013-06-12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global variables.
(defvar my-keys-minor-mode-map (make-keymap)
"Keymap for my-keys-minor-mode. See its docstring for more
@ -27,27 +26,124 @@ Example: to assign some-function to C-i, use
(if (not (file-directory-p emacs-cache-folder))
(make-directory emacs-cache-folder t))
;; Load config easily.
(add-to-list 'load-path "~/.emacs.d")
;; Local plugin folder for quick install. All files in this folder will be
;; accessible to Emacs config.
(add-to-list 'load-path "~/.emacs.d/plugins")
;; accessible to Emacs config. This is done to separate the versioned config
;; files from the external packages. For instance you can put package.el in
;; there for Emacs <24.
(add-to-list 'load-path "~/.emacs.d/local")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load main config
(load "~/.emacs.d/functions" nil t)
(load "~/.emacs.d/main" nil t)
(load "~/.emacs.d/mode-cc.el" nil t)
(load "~/.emacs.d/mode-dot.el" nil t)
(load "~/.emacs.d/mode-mediawiki.el" nil t)
(load "~/.emacs.d/mode-python.el" nil t)
(load "~/.emacs.d/mode-shell.el" nil t)
(load "~/.emacs.d/mode-tex.el" nil t)
(load "~/.emacs.d/mode-texinfo.el" nil t)
(load "~/.emacs.d/personal" nil t)
(load "~/.emacs.d/snippets.el" nil t)
(load "~/.emacs.d/theme" nil t)
(require 'functions nil t)
(require 'main nil t)
(require 'theme nil t)
(require 'personal nil t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Vanilla modes
;; Major modes
(add-hook 'awk-mode-hook (lambda () (require 'mode-awk)))
(add-hook 'c++-mode-hook (lambda () (require 'mode-cc)))
(add-hook 'c-mode-hook (lambda () (require 'mode-cc)))
(add-hook 'latex-mode-hook (lambda () (require 'mode-latex)))
(add-hook 'makefile-mode-hook (lambda () (require 'mode-makefile)))
(add-hook 'perl-mode-hook (lambda () (require 'mode-perl)))
(add-hook 'python-mode-hook (lambda () (require 'mode-python)))
(add-hook 'sh-mode-hook (lambda () (require 'mode-sh)))
(add-hook 'tex-mode-hook (lambda () (require 'mode-tex)))
(add-hook 'texinfo-mode-hook (lambda () (require 'mode-texinfo)))
;; Minor modes
(add-hook 'dired-mode-hook (lambda () (require 'mode-dired)))
(add-hook 'ediff-mode-hook (lambda () (require 'mode-ediff)))
(add-hook 'eshell-mode-hook (lambda () (require 'mode-eshell)))
(add-hook 'gud-mode-hook (lambda () (require 'mode-gud)))
(add-hook 'octave-mode-hook (lambda () (require 'mode-octave)))
(add-hook 'org-mode-hook (lambda () (require 'mode-org)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Third-party modes
(when (require 'package nil t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(setq package-user-dir (concat emacs-cache-folder "elpa"))
(package-initialize))
(load-external "\\.l\\'" 'flex-mode nil 'c-mode)
(load-external "\\.yy?\\'" 'bison-mode nil 'c-mode)
(load-external "\\.vert\\'\\|\\.frag\\'\\|\\.glsl\\'" 'glsl-mode nil 'c-mode)
(load-external "\\.go\\'" 'go-mode)
(load-external "\\.dot\\'" 'graphviz-dot-mode)
(add-hook 'graphviz-dot-mode-hook (lambda () (require 'mode-dot)))
(load-external "\\.lua\\'" 'lua-mode nil 'sh-mode)
(add-hook 'lua-mode-hook (lambda () (require 'mode-lua)))
(load-external "\\.md\\'\\|\\.markdown\\'" 'markdown-mode)
;; If we need more option, add it to a dedicated file.
(add-hook 'markdown-mode-hook (lambda () (set (make-local-variable 'paragraph-start) "
")))
(load-external "\\.wiki\\'" 'mediawiki 'mediawiki-mode)
(add-hook 'mediawiki-mode-hook (lambda () (require 'mode-mediawiki)))
;; .po support. This mode has no hooks.
(load-external "\\.po\\'\\|\\.po\\." 'po-mode)
(when (fboundp 'po-find-file-coding-system)
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Third-party tools
(autoload 'guess-style-set-variable "guess-style" nil t)
(autoload 'guess-style-guess-variable "guess-style")
(autoload 'guess-style-guess-all "guess-style" nil t)
(setq guess-style-info-mode 1)
(add-hook 'prog-mode-hook (lambda () (ignore-errors (guess-style-guess-all))))
(autoload 'pdf-view "tool-pdf" nil t)
(autoload 'pdf-compress "tool-pdf" nil t)
(autoload 'itranslate "tool-itranslate" nil t)
(autoload 'itranslate-lines "tool-itranslate" nil t)
(autoload 'itranslate-region "tool-itranslate" nil t)
(when (require 'multiple-cursors nil t)
(setq mc/list-file (concat emacs-cache-folder "mc-lists.el"))
;; Load the file at the new location.
(load mc/list-file t)
(global-unset-key (kbd "C-<down-mouse-1>"))
(define-key my-keys-minor-mode-map (kbd "C-<mouse-1>") 'mc/add-cursor-on-click)
(define-key my-keys-minor-mode-map (kbd "C-x M-r") 'mc/edit-lines)
(define-key my-keys-minor-mode-map (kbd "C-x M-m") 'mc/mark-more-like-this-extended)
(define-key my-keys-minor-mode-map (kbd "C-x M-l") 'mc/mark-all-like-this-dwim))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; We need to put it at the end to make sure it doesn't get overriden by other
;; minor modes.
(my-keys-minor-mode 1)
;; Local hook. You can use it to set system specific variables, such as the
;; external web browser or pdf viewer. You can also backport feature for old
;; Emacs. For instance:
; (setq pdf-viewer "evince")
; (setq pdf-viewer-args nil)
; (mapcar
; (lambda (mode-hook)
; (add-hook mode-hook (lambda () (run-hooks 'prog-mode-hook))))
; '(asm-mode-hook awk-mode-hook c++-mode-hook c-mode-hook
; emacs-lisp-mode-hook lisp-mode-hook lua-mode-hook
; makefile-mode-hook octave-mode-hook perl-mode-hook
; python-mode-hook scheme-mode-hook sh-mode-hook))
(load "local" t t)
;; End of file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -2,10 +2,28 @@
;; MAIN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Minimal UI. Load early to hide as soon as possible.
(setq inhibit-startup-screen t)
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(menu-bar-mode -1)
(when (fboundp 'set-scroll-bar-mode)
(set-scroll-bar-mode 'left)
(scroll-bar-mode -1)
(define-key my-keys-minor-mode-map (kbd "C-<f6>") 'toggle-scroll-bar))
;; Remember last cursor position.
(require 'saveplace)
(setq save-place-file (concat emacs-cache-folder "saveplace"))
(setq-default save-place t)
;; When the daemon is killed abruptly, places are not saved. Adding this hook
;; allows to save places at a strategic moment.
(add-hook 'before-save-hook 'save-place-kill-emacs-hook)
;; url-cookie
(setq url-cookie-file (concat emacs-cache-folder "url.cookies"))
;; Bookmark file to cache folder.
(setq bookmark-default-file (concat emacs-cache-folder "emacs.bmk"))
;; Disable autosave features.
(setq auto-save-default nil)
@ -27,21 +45,13 @@
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z"))
;; For convenience.
(setq inhibit-startup-screen t)
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(menu-bar-mode -1)
(when (fboundp 'set-scroll-bar-mode)
(set-scroll-bar-mode 'left)
(scroll-bar-mode -1)
(define-key my-keys-minor-mode-map (kbd "C-<f6>") 'toggle-scroll-bar))
;; Make questions less annoying.
(defalias 'yes-or-no-p 'y-or-n-p)
;; Allow some protected functions.
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
;; Print column number in mode line.
(column-number-mode 1)
@ -67,9 +77,11 @@
(condition-case nil (scroll-down)
(beginning-of-buffer (goto-char (point-min)))))))
(define-key my-keys-minor-mode-map (kbd "C-x M-n") (lambda () (interactive) (narrow-to-page 1)))
(define-key my-keys-minor-mode-map (kbd "C-x M-p") (lambda () (interactive) (narrow-to-page -1)))
;; Line numbers
;; TODO: This mode is slow on big files when using beginning-of-buffer binding.
(autoload 'linum-mode "linum" "toggle line numbers on/off" t)
;; TODO: This mode is slow on big files when using beginning-of-buffer binding.
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
(define-key my-keys-minor-mode-map (kbd "C-<f5>") 'linum-mode)
(add-hook
@ -79,36 +91,45 @@
;; Indentation
(setq-default tab-width 4)
(setq-default standard-indent 4)
(setq-default c-basic-offset 4)
(setq-default indent-tabs-mode nil) ;; Indentation cannot insert tabs
;; Line by line scrolling
(setq scroll-step 1)
;; Useful of autofill.
(setq sentence-end-double-space nil)
;; Highlight selections -- not activated by default on old Emacs.
(transient-mark-mode 1)
;; No trailing whitespace
;; Whitespace, tabs, and other frivolities. Highlight trailing whitespaces. For
;; programming languages only, so that it does not affect buffer like calendar
;; and so on. There is no prog-mode-hook on Emacs<24.
(require 'functions) ; for page-number-mode
(add-hook
'prog-mode-hook
(lambda ()
(page-number-mode t)
(whitespace-mode)))
(define-key my-keys-minor-mode-map (kbd "C-<f7>") 'whitespace-mode)
;; WARNING: this can break some configuration files needing whitespaces at the
;; end.
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Highlight trailing whitespaces. For programming languages only, so that it
;; does not affect buffer like calendar and so on. There is no prog-mode-hook on
;; Emacs<24.
(mapcar
(lambda (mode-hook)
(add-hook
mode-hook
(lambda () (interactive)
(setq show-trailing-whitespace t))))
'(prog-mode-hook lua-mode-hook))
; (add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq whitespace-style (quote (face trailing tab-mark)))
;; TODO: whitespace report-on-bogus and cleanup do not seem to work properly.
;; Empty lines seems to be always true. Report is shown even when style is not
;; matching the errors.
; (setq whitespace-action '(report-on-bogus))
;; Remove whitespaces on region, or whole file.
(define-key my-keys-minor-mode-map (kbd "C-\\") 'delete-trailing-whitespace)
;; Hippie expand.
(define-key my-keys-minor-mode-map (kbd "M-/") 'hippie-expand)
;; Abbreviation support
(setq default-abbrev-mode t)
(setq-default abbrev-mode t)
;; Set Fill Column
(setq-default fill-column 80)
@ -129,17 +150,17 @@
browse-url-browser-function 'browse-url-generic)
(define-key my-keys-minor-mode-map (kbd "C-M-u") 'browse-url)
;; Default ispell dictionnay
;; (setq ispell-dictionary "fr")
;; Default ispell dictionnay. If not set, Emacs uses the current locale.
(setq ispell-dictionary "en")
(define-key my-keys-minor-mode-map
(kbd "C-<f7>")
(kbd "<f5>")
(lambda () (interactive) (ispell-change-dictionary "en")))
(define-key my-keys-minor-mode-map
(kbd "C-<f8>")
(kbd "<f6>")
(lambda () (interactive) (ispell-change-dictionary "fr")))
;; Use color escape sequences. Only use if needed.
;; (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(define-key my-keys-minor-mode-map
(kbd "<f7>")
(lambda () (interactive) (ispell-change-dictionary "sv")))
;; Long paragraphs. Useful for quick navigation with backward-paragraph and
;; forward-paragraph.
@ -156,7 +177,7 @@
(if (not (fboundp 'tool-bar-mode)) (define-key my-keys-minor-mode-map (kbd "C-M-y") 'query-replace-regexp))
;; Semantic options.
(semantic-mode 1)
(semantic-mode 0)
(setq semanticdb-default-save-directory (concat emacs-cache-folder "semanticdb"))
(define-key my-keys-minor-mode-map (kbd "C-c , d") 'semantic-ia-show-summary)
(define-key my-keys-minor-mode-map (kbd "C-, d") 'semantic-ia-show-summary)
@ -177,8 +198,9 @@
;; Run ranger asynchronously.
(define-key my-keys-minor-mode-map (kbd "C-x D")
(lambda () (interactive)
(shell-command "urxvt -e ranger &")
(delete-windows-on "*Async Shell Command*")))
(let ((term (getenv "TERMCMD")))
(when (and (executable-find "ranger") (executable-find term))
(start-process "dummy" nil term "-e" "ranger")))))
;; Calendar ISO display.
(setq calendar-week-start-day 1)
@ -194,6 +216,9 @@
;; IDO.
;; (ffap-bindings)
;; Icomplete
(icomplete-mode)
;; Quick buffer switching.
(define-key my-keys-minor-mode-map (kbd "C-<prior>") 'previous-buffer)
(define-key my-keys-minor-mode-map (kbd "C-<next>") 'next-buffer)
@ -203,76 +228,6 @@
(lambda () (interactive)
(buffer-menu 1)))
;; Disable prompt (but leave warning) on git symlink.
(setq vc-follow-symlinks t)
;; Org mode config.
;; Move annoying babel folder. This move does not seem to work properly.
(setq org-babel-temporary-directory (concat emacs-cache-folder "babel"))
;; Disable line splitting on M-RET
(setq org-M-RET-may-split-line '((default)))
(add-hook
'org-mode-hook
(lambda ()
(setq org-agenda-files '("~/todo.org"))
(auto-fill-mode -1)
(setq org-enforce-todo-dependencies t)))
;; Set PDF association in Org-mode (was Evince by default).
(eval-after-load "org"
'(progn
;; Change .pdf association directly within the alist
(setcdr (assoc "\\.pdf\\'" org-file-apps) "zathura --fork %s")))
;; Ediff in one frame.
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; Set GUD to display many windows by default.
;; (setq gdb-show-main t)
(setq gdb-many-windows t)
;; Change GUD many-windows layout.
(add-hook
'gud-mode-hook
(lambda ()
(defun gdb-setup-windows ()
"Layout the window pattern for `gdb-many-windows'."
(setq gdb-source-window (selected-window))
(gdb-display-locals-buffer)
(delete-other-windows)
(gdb-display-stack-buffer)
(delete-other-windows)
(gdb-display-breakpoints-buffer)
(delete-other-windows)
;; TODO: this does not behave the same on Emacs 23 and 24.
(switch-to-buffer
(if gud-last-last-frame
(gud-find-file (car gud-last-last-frame))
(if gdb-main-file
(gud-find-file gdb-main-file)
;; Put buffer list in window if we can't find a source file.
(list-buffers-noselect))))
(split-window-horizontally)
(other-window 1)
(split-window nil ( / ( * (window-height) 3) 4))
(split-window nil ( / (window-height) 3))
(gdb-set-window-buffer (gdb-locals-buffer-name))
(other-window 1)
(gdb-set-window-buffer gud-comint-buffer)
(when (and
(boundp 'gdb-use-separate-io-buffer)
gdb-use-separate-io-buffer)
(split-window-horizontally)
(other-window 1)
(gdb-set-window-buffer
(gdb-get-buffer-create 'gdb-inferior-io)))
(other-window 1)
(gdb-set-window-buffer (gdb-stack-buffer-name))
(split-window-horizontally)
(other-window 1)
(gdb-set-window-buffer (gdb-breakpoints-buffer-name))
(other-window 1))))
;; Remove auto-fill in dwb edit because wikis and forums do not like it.
(add-hook
'find-file-hook
@ -287,16 +242,19 @@
(speedbar-toggle-updates)))
;; Compilation bindings and conveniences.
(setq compilation-hide-window nil)
(define-key my-keys-minor-mode-map (kbd "<f10>")
(lambda () (interactive)
(save-buffer)
(compile compile-command)
(when compilation-hide-window
(sit-for 2)
(delete-windows-on "*compilation*"))))
(require 'functions)
(setq compilation-ask-about-save nil)
(autoload 'recompile "compile" nil t)
(define-key my-keys-minor-mode-map (kbd "<f10>") 'compile-custom)
(define-key my-keys-minor-mode-map (kbd "<f11>") 'previous-error)
(define-key my-keys-minor-mode-map (kbd "<f12>") 'next-error)
(add-hook
'compilation-after-hook
(lambda ()
(when compilation-time-before-hide-window
(sit-for compilation-time-before-hide-window)
(delete-windows-on "*compilation*"))))
;; Code browsing: make C-M-e jump to next function instead of the end of the current function.
(define-key my-keys-minor-mode-map (kbd "C-M-e") (lambda () (interactive) (beginning-of-defun -1)))
@ -310,100 +268,6 @@
;; Common LISP
(setq inferior-lisp-program "clisp")
;; Flymake has a bug that prevents menu from spawning in a console. We redefine
;; the function to spawn the error message in the mini-buffer.
(defun flymake-display-err-message-for-current-line ()
"Display a message with errors/warnings for current line if it
has errors and/or warnings."
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(menu-data (flymake-make-err-menu-data line-no line-err-info-list)))
(if menu-data
(let ((messages))
(push (concat (car menu-data) ":") messages)
(dolist (error-or-warning (cadr menu-data))
(push (car error-or-warning) messages))
(message "%s" (mapconcat #'identity (reverse messages) "\n"))))))
(define-key my-keys-minor-mode-map (kbd "C-<f10>")
'flymake-display-err-message-for-current-line)
;; Ediff split horizontally by default.
;; TODO: does not seem to work.
(add-hook
'ediff-mode-hook
(lambda ()
(setq ediff-merge-split-window-function 'split-window-horizontally)))
;; Eshell
(setq eshell-directory-name (concat emacs-cache-folder "eshell"))
;; (setq eshell-aliases-file (concat user-emacs-directory "eshell-alias"))
;; TODO: this breaks eshell completion and history.
;; (setq eshell-prompt-function
;; (lambda nil
;; (let ((path (abbreviate-file-name (eshell/pwd))))
;; (concat ".-(" path ")"
;; (make-string (- (window-body-width) 5 (length path)) ?-)
;; "\n`--"
;; (if (= (user-uid) 0) "# " "> ")))))
(add-hook
'eshell-mode-hook
(lambda ()
(nconc eshell-visual-commands
'("abook" "cmus" "htop" "mutt" "ncdu" "newsbeuter" "ranger"
"rtorrent" "task" "tig"))
(when (file-executable-p "/usr/bin/pacman")
(map-on-pair 'eshell/alias
'(("pc" "sudo pacman -Sc")
("pi" "sudo pacman -S --needed")
("pqi" "pacman -Qi")
("pqo" "pacman -Qo")
("pqs" "pacman -Qs")
("pr" "sudo pacman -Rs")
("psi" "pacman -Si")
("pss" "pacman -Ss")
("pu" "sudo pacman -Syu"))))
(map-on-pair 'eshell/alias
'(("mkdir" "mkdir -p")
("lx" "ls -lXh")
("lx" "ls -lXh")
("lk" "ls -lSrh")
("lc" "ls -lrc")
("ll" "ls -hl")
("la" "ls -ahl")))))
;; Zlc - Zsh style completion.
;; (if (require 'zlc nil t)
;; (let ((map minibuffer-local-map))
;; ;; Like Zsh menu select. Should not use arrows directly because it overrides
;; ;; default controls like previous entry, or previous/next char.
;; (define-key map (kbd "M-<down>") 'zlc-select-next-vertical)
;; (define-key map (kbd "M-<up>") 'zlc-select-previous-vertical)
;; (define-key map (kbd "M-<right>") 'zlc-select-next)
;; (define-key map (kbd "M-<left>") 'zlc-select-previous)
;; ;; Reset selection.
;; (define-key map (kbd "C-c") 'zlc-reset)
;; ;; (setq zlc-select-completion-immediately t)
;; ;; To change style, M-x customize-face and input zlc-selected-completion-face.
;; ))
;; xclip
(if (require 'xclip nil t)
(turn-on-xclip))
;; Multiple-Cursors
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/multiple-cursors")
(if (require 'multiple-cursors nil t)
(progn
(setq mc/list-file (concat emacs-cache-folder "mc-lists.el"))
(global-unset-key (kbd "C-<down-mouse-1>"))
(define-key my-keys-minor-mode-map (kbd "C-<mouse-1>") 'mc/add-cursor-on-click)
(define-key my-keys-minor-mode-map (kbd "C-c C-r") 'mc/edit-lines)
(define-key my-keys-minor-mode-map (kbd "C-c C-m") 'mc/mark-more-like-this-extended)
(define-key my-keys-minor-mode-map (kbd "C-c C-l") 'mc/mark-all-like-this-dwim)))
;; Let Emacs auto-load/save sessions.
(when (boundp 'server-running-p)
(desktop-save-mode 1)
@ -414,150 +278,42 @@ has errors and/or warnings."
(setq desktop-path `(,desktop-dirname))
(add-to-list 'desktop-globals-to-save 'compile-command))
(defadvice pop-to-buffer (before cancel-other-window first)
(ad-set-arg 1 nil))
(ad-activate 'pop-to-buffer)
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
(current-buffer)))
;; Press [pause] key in each window you want to "freeze", i.e. prevent Emacs
;; from acting on it.
(global-set-key [pause] 'toggle-window-dedicated)
;; Dired options
;; On a GNU system, ls has the option to sort folders first.
(if (string-match "^gnu.*" (prin1-to-string system-type))
(setq dired-listing-switches "--group-directories-first -lh")
(setq dired-listing-switches "-lh"))
(setq wdired-allow-to-change-permissions t)
(defvar dired-showing-hidden nil "If dired is displaying hidden files or not.")
(defvar dired-showing-humansize t "If dired is displaying humansize or not.")
(defun dired-toggle-hidden ()
"Toggle displaying hidden files in dired."
(interactive)
(let (;; Regexp for finding (possibly embedded) -a switches.
(switch-regexp "\\(\\`\\| \\)-\\([b-zA-Z]*\\)\\(a\\)\\([^ ]*\\)")
case-fold-search)
;; Remove the -a switch.
(while (string-match switch-regexp dired-actual-switches)
(if (and (equal (match-string 2 dired-actual-switches) "")
(equal (match-string 4 dired-actual-switches) ""))
;; Remove a stand-alone -a switch.
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches))
;; Remove a switch of the form -XaY for some X and Y.
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches 3))))
;; Now, if we weren't sorting by date before, add the -a switch. Some
;; simple-minded ls implementations (eg ftp servers) only allow a single
;; option string, so try not to add " -a" if possible.
(if dired-showing-hidden
(setq dired-showing-hidden nil)
(progn
(setq dired-actual-switches
(concat dired-actual-switches
(if (string-match-p "\\`-[[:alnum:]]+\\'"
dired-actual-switches)
"a" " -a")))
(setq dired-showing-hidden t))))
;; (dired-sort-set-mode-line)
(revert-buffer))
(defun dired-toggle-humansize ()
"Toggle displaying humansize in dired."
(interactive)
(let ((switch-regexp "\\(\\`\\| \\)-\\([a-gi-zA-Z]*\\)\\(h\\)\\([^ ]*\\)")
case-fold-search)
(while (string-match switch-regexp dired-actual-switches)
(if (and (equal (match-string 2 dired-actual-switches) "")
(equal (match-string 4 dired-actual-switches) ""))
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches))
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches 3))))
(if dired-showing-humansize
(setq dired-showing-humansize nil)
(progn
(setq dired-actual-switches
(concat dired-actual-switches
(if (string-match-p "\\`-[[:alnum:]]+\\'"
dired-actual-switches)
"h" " -h")))
(setq dired-showing-humansize t))))
(revert-buffer))
(add-hook
'dired-mode-hook
(lambda ()
(local-set-key (kbd "C-c a") 'dired-toggle-hidden)
(local-set-key (kbd "C-c h") 'dired-toggle-humansize)
(local-set-key (kbd "<left>") 'dired-up-directory)
(local-set-key (kbd "<right>") 'dired-find-file)
(local-set-key (kbd "SPC") 'dired-mark)
(local-set-key (kbd "<backspace>") 'dired-up-directory)
(local-set-key (kbd "b") 'dired-up-directory)))
;; GMP
;; GMP documentation
(eval-after-load "info-look"
'(let ((mode-value (assoc 'c-mode (assoc 'symbol info-lookup-alist))))
(setcar (nthcdr 3 mode-value)
(cons '("(gmp)Function Index" nil "^ -.* " "\\>")
(nth 3 mode-value)))))
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; Bookmark file to cache folder
(setq bookmark-default-file (concat emacs-cache-folder "emacs.bmk"))
;; Skeleton settings
(require 'functions)
;; Do not expand abbrevs in skeletons.
(setq-default skeleton-further-elements '((abbrev-mode nil)))
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
(define-key my-keys-minor-mode-map (kbd "C->") 'skeleton-next-position)
(define-key my-keys-minor-mode-map (kbd "C-<") (lambda () (interactive) (skeleton-next-position t)))
;; GLSL fallback to C mode.
(add-to-list 'auto-mode-alist '("\\.vert\\'" . c-mode))
(add-to-list 'auto-mode-alist '("\\.frag\\'" . c-mode))
(add-to-list 'auto-mode-alist '("\\.glsl\\'" . c-mode))
(autoload 'glsl-mode "glsl-mode" nil t)
(when (boundp 'glsl-mode)
(add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode))
(add-to-list 'auto-mode-alist '("\\.glsl\\'" . glsl-mode)))
;; Alternate focus.
(add-hook 'occur-hook (lambda () (pop-to-buffer occur-buf)))
;; (add-hook 'help-mode-hook (lambda () (pop-to-buffer (get-buffer "*Help*"))))
(add-hook 'grep-mode-hook (lambda () (pop-to-buffer (get-buffer "*grep*"))))
;; Lua
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
;; Disable prompt (but leave warning) on git symlink.
(setq vc-follow-symlinks t)
;; Go
(require 'go-mode-load nil t)
;; Clipboard and primary selection.
(setq x-select-enable-clipboard t)
(setq x-select-enable-primary t)
;; Bison/flex -- Fallback to c-mode.
(add-to-list 'auto-mode-alist '("\\.yy?\\'" . c-mode))
(add-to-list 'auto-mode-alist '("\\.l\\'" . c-mode))
(if (require 'bison-mode nil t)
(add-to-list 'auto-mode-alist '("\\.yy?\\'" . bison-mode)))
(if (require 'flex-mode nil t)
(add-to-list 'auto-mode-alist '("\\.l\\'" . flex-mode)))
;; Bibtex
(setq bibtex-entry-format '(opts-or-alts required-fields numerical-fields whitespace realign last-comma delimiters braces sort-fields))
(setq bibtex-field-delimiters 'double-quotes)
;; Markdown
(autoload 'markdown-mode "markdown-mode" "Markdown mode" t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-hook
'markdown-mode-hook
(lambda ()
(set (make-local-variable 'paragraph-start) "
")))
;; Read Matlab files in Octave mode.
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))
;; Git commit meessages.
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG\\'" . conf-mode))
;; Mutt support.
(add-to-list 'auto-mode-alist '("/tmp/mutt.*" . mail-mode))
@ -573,5 +329,35 @@ has errors and/or warnings."
;; Subtitles support.
(add-to-list 'auto-mode-alist '("\\.srt\\'" . text-mode))
;; Git commit meessages.
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG\\'" . conf-mode))
;; Read Matlab files in Octave mode.
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'main)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This may be needed for gud/pdb.
; (defadvice pop-to-buffer (before cancel-other-window first)
; (ad-set-arg 1 nil))
; (ad-activate 'pop-to-buffer)
;; Use color escape sequences. Only use if needed.
; (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; Flymake has a bug that prevents menu from spawning in a console. We redefine
;; the function to spawn the error message in the mini-buffer.
; (defun flymake-display-err-message-for-current-line ()
; "Display a message with errors/warnings for current line if it
; has errors and/or warnings."
; (interactive)
; (let* ((line-no (flymake-current-line-no))
; (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
; (menu-data (flymake-make-err-menu-data line-no line-err-info-list)))
; (if menu-data
; (let ((messages))
; (push (concat (car menu-data) ":") messages)
; (dolist (error-or-warning (cadr menu-data))
; (push (car error-or-warning) messages))
; (message "%s" (mapconcat #'identity (reverse messages) "\n"))))))
; (define-key my-keys-minor-mode-map (kbd "C-<f10>")
; 'flymake-display-err-message-for-current-line)

68
.emacs.d/mode-awk.el Normal file
View File

@ -0,0 +1,68 @@
;;==============================================================================
;; AWK
;;==============================================================================
(add-hook-and-eval
'sh-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-f") 'awk-fori)
(local-set-key (kbd "C-c f") 'awk-forin)
(local-set-key (kbd "C-c C-i") 'awk-if)
(local-set-key (kbd "C-c (") 'awk-function)
(local-set-key (kbd "C-c C-p") 'awk-printf)
(set (make-local-variable 'compile-command) (concat "awk " buffer-file-name))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-skeleton awk-fori
"for i loop."
nil
> "for (" @ (skeleton-read "" "i = 0") "; " @ (skeleton-read "" "i < N") "; " @ (skeleton-read "" "i++") ") {" \n
@ _ \n
"}" > )
(define-skeleton awk-forin
"for in loop."
nil
> "for (" @ (skeleton-read "" "var") " in " @ (skeleton-read "" "array") ") {" \n
@ _ \n
"}" > )
(define-skeleton awk-function
"Insert struction for function"
nil
"function " @ (skeleton-read "Name: ") " (" @ (skeleton-read "Args: ") ") {" \n
> _ \n
"}" > \n)
(define-skeleton awk-if
"Insert an if statement."
"Condition: "
> "if (" @ str ") {" \n
> @ _ \n
("Other condition, %s: "
"} else if (" > @ str ") {" \n
@ \n)
"} else {" > \n
@ \n
resume:
"}" > \n)
(define-skeleton awk-printf
"fprintf/printf snippet.
If no file descriptor is provided, switch do printf. The format
string is properly parsed (%% are not taken into account).\n
Requires `count-percents'."
nil
'(require 'functions)
"printf ("
"\"" (setq v1 (skeleton-read "Format string: " "%s\\n")) "\""
'(setq v2 (count-percents v1))
'(setq v1 0)
'(while (< v1 v2)
(setq v1 (1+ v1))
(skeleton-insert '(nil (concat ", " (skeleton-read "Value: ")))))
@ ")")
(provide 'mode-awk)

View File

@ -1,53 +1,46 @@
;;==============================================================================
;; C/C++
;;==============================================================================
(require 'compile)
;; Note: maybe this should be split in mode-c and mode-c++.
(defun get-closest-pathname (&optional file)
"Determine the pathname of the first instance of FILE starting
from the current directory towards root. This may not do the
correct thing in presence of links. If it does not find FILE,
then it shall return the name of FILE in the current directory,
suitable for creation"
(let ((current-dir default-directory) (looping t) (makefile (or file "Makefile")))
(while (progn
(if (file-exists-p (expand-file-name makefile current-dir))
(setq looping nil)
(setq current-dir (expand-file-name ".." current-dir)))
(and looping (not (equal current-dir "/")))))
(if (equal current-dir "/") nil (expand-file-name makefile current-dir))))
(defcustom mode-cc-ldlibs "-lm -pthread"
"[Local variable] Custom linker flags for C/C++ linkage."
(defcustom cc-ldlibs "-lm -pthread"
"Custom linker flags for C/C++ linkage."
:safe 'stringp)
(make-variable-buffer-local 'cc-ldlibs)
(defcustom mode-cc-ldflags ""
"[Local variable] Custom linker libs for C/C++ linkage."
(defcustom cc-ldflags ""
"Custom linker libs for C/C++ linkage."
:safe 'stringp)
(make-variable-buffer-local 'cc-ldflags)
(defun cc-set-compiler ()
"Set C/C++ compile command to be nearest Makefile found in
parent folders. If no Makefile is found, then a configurable
command line is provided."
(interactive)
(if (get-closest-pathname)
(set (make-local-variable 'compile-command) (format "make -k -f %s" (get-closest-pathname)))
(set (make-local-variable 'compile-command)
(let
((is-cpp (equal (symbol-name major-mode) "c++-mode"))
(file (file-name-nondirectory buffer-file-name)))
(format "%s %s -o %s %s %s %s"
(if is-cpp
(or (getenv "CXX") "g++")
(or (getenv "CC") "gcc"))
file
(file-name-sans-extension file)
(if is-cpp
(or (getenv "CPPFLAGS") "-Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0")
(or (getenv "CFLAGS") "-ansi -pedantic -std=c99 -Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0"))
(or (getenv "LDFLAGS") mode-cc-ldflags)
(or (getenv "LDLIBS") mode-cc-ldlibs))))))
(defun cc-set-compiler (&optional nomakefile)
"Set compile command to be nearest Makefile or a generic command.
The Makefile is looked up in parent folders. If no Makefile is
found (or if NOMAKEFILE is non-nil or if function was called with
universal argument), then a configurable command line is
provided.\n Requires `get-closest-pathname'."
(interactive "P")
(require 'functions)
(hack-local-variables)
(let ((makefile (get-closest-pathname)))
(if (and makefile
(not nomakefile))
(set (make-local-variable 'compile-command) (format "make -k -C %s" (file-name-directory makefile)))
(set (make-local-variable 'compile-command)
(let
((cppp (eq major-mode 'c++-mode))
(file (file-name-nondirectory buffer-file-name)))
(format "%s %s -o %s %s %s %s"
(if cppp
(or (getenv "CXX") "g++")
(or (getenv "CC") "gcc"))
file
(file-name-sans-extension file)
(if cppp
(or (getenv "CPPFLAGS") "-Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0")
(or (getenv "CFLAGS") "-ansi -pedantic -std=c99 -Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0"))
(or (getenv "LDFLAGS") cc-ldflags)
(or (getenv "LDLIBS") cc-ldlibs)))))))
(defun cc-clean ()
"Find Makefile and call the `clean' rule. If no Makefile is
@ -56,87 +49,57 @@ restored."
(interactive)
(when (get-closest-pathname)
(let ((compile-command-backup compile-command))
(compile (format "make -k -f %s clean" (get-closest-pathname)))
(compile (format "make -k -f '%s' clean" (get-closest-pathname)))
(setq compile-command compile-command-backup))))
;;==============================================================================
;; C-mode
;;==============================================================================
;; Identation style
(setq c-default-style "linux" c-basic-offset 4)
(c-add-style
"peter"
'((c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist
(brace-list-open)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)
(arglist-cont-nonempty))
(c-cleanup-list brace-else-brace)
(c-offsets-alist
(statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(substatement-label . 0)
(label . 0)
(case-label . +)
(statement-cont . +))))
(add-hook
'c-mode-hook
(lambda ()
(cc-set-compiler)
(local-set-key (kbd "<f9>") 'cc-clean)
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
(local-set-key (kbd "C-M-e") (lambda () (interactive) (c-beginning-of-defun -1)))
;; (local-set-key "." 'semantic-complete-self-insert) ; This is a bit slow.
;; (local-set-key ">" 'semantic-complete-self-insert)
))
;;==============================================================================
;; C++-mode
;;==============================================================================
(require 'compile)
;; TODO: test this!
;; (defun vlad-cc-style()
;; (c-set-style "linux")
;; (c-set-offset 'innamespace '0)
;; (c-set-offset 'inextern-lang '0)
;; (c-set-offset 'inline-open '0)
;; (c-set-offset 'label '*)
;; (c-set-offset 'case-label '*)
;; (c-set-offset 'access-label '/)
;; (setq c-basic-offset 4)
;; (setq tab-width 4)
;; (setq indent-tabs-mode nil)
;; )
;; (add-hook 'c++-mode-hook 'vlad-cc-style)
(add-hook
'c++-mode-hook
(lambda ()
(cc-set-compiler)
(local-set-key (kbd "<f9>") 'cc-clean)
(local-set-key (kbd "C-M-e") (lambda () (interactive) (c-beginning-of-defun -1)))
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)))
;; autoinsert C/C++ header
(define-auto-insert
(cons "\\.\\([Hh]\\|hh\\|hpp\\)\\'" "My C / C++ header")
'(nil
"/" (make-string 79 ?*) "\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @date \n"
" * @brief \n"
" *\n"
" " (make-string 78 ?*) "/\n\n"
(let* ((noext (substring buffer-file-name 0 (match-beginning 0)))
(nopath (file-name-nondirectory noext))
(ident (concat (upcase nopath) "_H")))
(concat "#ifndef " ident "\n"
"#define " ident " 1\n\n\n"
"\n\n#endif // " ident "\n"))))
;; auto insert C/C++
(define-auto-insert
(cons "\\.\\([Cc]\\|cc\\|cpp\\)\\'" "My C++ implementation")
'(nil
"/" (make-string 79 ?*) "\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @date \n"
" * @brief \n"
" *\n"
" " (make-string 78 ?*) "/\n\n"
(let* ((noext (substring buffer-file-name 0 (match-beginning 0)))
(nopath (file-name-nondirectory noext))
(ident (concat nopath ".h")))
(if (file-exists-p ident)
(concat "#include \"" ident "\"\n")))))
;; Note that in Emacs 24, cc-mode calls its hooks manually in each mode init
;; function. Since cc modes belong to prog-mode, each hook is called another
;; time at the end of the initialization. No big deal since we only set some
;; variables.
(mapcar
(lambda (mode-hook)
(add-hook-and-eval
mode-hook
(lambda ()
(c-set-style "peter")
(add-hook 'compilation-before-hook 'cc-set-compiler nil t)
(local-set-key (kbd "<f9>") 'cc-clean)
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
(local-set-key (kbd "C-c (") 'cc-function)
(local-set-key (kbd "C-c C-f") 'cc-for)
(local-set-key (kbd "C-c C-i") 'cc-if)
(local-set-key (kbd "C-c C-p") 'cc-printf)
(local-set-key (kbd "C-c I") 'cc-include-local)
(local-set-key (kbd "C-c i") 'cc-include)
(local-set-key (kbd "C-c m") 'cc-main)
;; (local-set-key "." 'semantic-complete-self-insert) ; This is a bit slow.
;; (local-set-key ">" 'semantic-complete-self-insert)
(local-set-key (kbd "C-M-e") (lambda () (interactive) (c-beginning-of-defun -1))))))
'(c-mode-hook c++-mode-hook))
;;==============================================================================
;; Qt semantic support
@ -144,7 +107,7 @@ restored."
;; Qt base directory, meaning the directory where the 'Qt' directory can be found.
;; Adapt accordingly.
(when (fboundp 'semantic-add-system-include)
(when (fboundp 'semantic-add-system-include)
(setq qt4-base-dir "/usr/include/qt4")
(setq qt4-gui-dir (concat qt4-base-dir "/QtGui"))
(semantic-add-system-include qt4-base-dir 'c++-mode)
@ -153,6 +116,221 @@ restored."
(add-hook
'c++-mode-hook
(lambda ()
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig-large.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qglobal.h")))))
(when semantic-mode
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qconfig-large.h"))
(add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat qt4-base-dir "/Qt/qglobal.h"))))))
;;==============================================================================
;; Skel
;;==============================================================================
;; Note that it is possible to extend the skel syntax with
;; `skeleton-further-elements'. For instance:
; (setq skeleton-further-elements '((q "\"")))
(define-skeleton cc-case
"Insert a case/switch statement."
"expression: "
> "switch (" str ") {" \n
( "Value, %s: "
> "case " > str ":" \n
> _ \n
"break;" \n)
"default:" > \n
> _ \n
"break;" \n
resume:
"}" > \n)
(define-skeleton cc-debug
"Insert debug macros."
nil
"#ifdef DEBUG
#define DEBUG_CMD(CMD) do {CMD;} while(0)
#else
#define DEBUG_CMD(CMD) do {} while(0)
#endif
#define DEBUG_STR(STR) DEBUG_CMD(fprintf(stderr, \":: %s\\n\", STR))
#define DEBUG_PRINT(...) DEBUG_CMD ( \\
fprintf(stderr, \"\\n\\033[31;1mDEBUG:\\033[0m %s:%d:%s()\\t\", __FILE__, __LINE__, __func__); \\
fprintf(stderr, __VA_ARGS__);\\
fprintf(stderr, \"\\n\"); \\
)")
(define-skeleton cc-for
"for loop."
nil
'(setq str (skeleton-read "Variable: " "i"))
> "for (" @ (skeleton-read "" (concat str " = 0")) "; "
@ (skeleton-read "" (concat str " < N")) "; "
@ (skeleton-read "" (concat str "++")) ") {" \n
@ _ \n
"}" > )
(define-skeleton cc-function
"Insert punctuation for function."
"Arguments: " '(just-one-space) "(" @ str ") {" \n
> _ \n
"}" > \n)
(define-skeleton cc-getopt
"Insert a getopt template."
nil
'(require 'functions)
'(insert-and-indent "int opt;
while ((opt = getopt (argc, argv, \":hV\")) != -1)
{
switch (opt)
{
case 'h':
usage (argv[0]);
return 0;
case 'V':
version ();
return 0;
case ':':
fprintf (stderr, \"ERROR: -%c needs an argument.\\nTry '%s -h' for more information.\\n\", optopt, argv[0]);
return EXIT_FAILURE;
case '?':
fprintf (stderr, \"ERROR: Unknown argument %c.\\nTry '%s -h' for more information.\\n\", optopt, argv[0]);
return EXIT_FAILURE;
default:
usage (argv[0]);
return EXIT_SUCCESS;
}
}
if (optind >= argc) {
fprintf(stderr, \"Expected argument after options\\n\");
exit (EXIT_FAILURE);
}"))
(define-skeleton cc-if
"Insert an if statement."
"Condition: "
> "if (" @ str ") {" \n
> @ _ \n
("Other condition, %s: "
"} else if (" > @ str ") {" \n
@ \n)
"} else {" > \n
@ \n
resume:
"}" > \n)
(define-skeleton cc-include
"Insert system include."
"Header: "
\n "#include <" @ str ">" \n)
(define-skeleton cc-include-local
"Insert local include."
"Header: "
\n "#include \"" @ str "\"" \n)
(define-skeleton cc-loadfile
"Insert loadfile function."
nil
"unsigned long loadfile (const char * path, char ** buffer_ptr) {
#define MAX_FILESIZE 1073741824 /* One gigabyte */
/* Handle variable. */
char* buffer;
FILE* file = fopen(path, \"rb\");
if (file == NULL)
{
perror(path);
return 0;
}
fseek(file, 0, SEEK_END);
long length = ftell(file);
/* fprintf (stdout, \"Note: file %s is %u bytes long.\\n\", path, length); */
if (length > MAX_FILESIZE)
{
fprintf (stderr, \"%s size %ld is bigger than %d bytes.\\n\", path, length, MAX_FILESIZE);
fclose(file);
return 0;
}
fseek(file, 0, SEEK_SET);
buffer = (char*)malloc(length + 1);
if (buffer == NULL)
{
perror(\"malloc\");
fclose(file);
return 0;
}
if(fread(buffer, 1, length, file) == 0)
{
fclose(file);
return 0;
}
buffer[length] = '\\0';
fclose(file);
*buffer_ptr = buffer;
return length;
}")
(define-skeleton cc-main
"Insert main function with basic includes."
nil
> "#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char** argv) {" \n
> @ _ \n
> "return EXIT_SUCCESS;
}" \n)
(define-skeleton cc-printf
"fprintf/printf snippet.
If no file descriptor is provided, switch do printf. The format
string is properly parsed (%% are not taken into account).\n
Requires `count-percents'."
nil
'(require 'functions)
'(setq v1 (skeleton-read "File desc: " "stderr"))
(if (string= v1 "") "printf (" (concat "fprintf (" v1 ", "))
"\"" (setq v1 (skeleton-read "Format string: " "%s\\n")) "\""
'(setq v2 (count-percents v1))
'(setq v1 0)
'(while (< v1 v2)
(setq v1 (1+ v1))
(skeleton-insert '(nil (concat ", " (skeleton-read "Value: ")))))
@ ");")
(define-skeleton cc-usage-version
"Insert usage() and version() functions."
"Synopsis"
> "static void usage (const char *executable) {
printf (\"Usage: %s [OPTIONS]\\n\\n\", executable);
puts (\"" str "\\n\");
puts (\"Options:\");
puts (\" -h Print this help.\");
puts (\" -V Print version information.\");
puts (\"\");
printf (\"See %s for more information.\\n\", MANPAGE);
}
static void version () {
printf (\"%s %s\\n\", APPNAME, VERSION);
printf (\"Copyright © %s %s\\n\", YEAR, AUTHOR);
}" \n)
(provide 'mode-cc)

62
.emacs.d/mode-dired.el Normal file
View File

@ -0,0 +1,62 @@
;; Dired options
;; On a GNU system, ls has the option to sort folders first.
(if (string-match "^gnu.*" (prin1-to-string system-type))
(setq dired-listing-switches "--group-directories-first -lha")
(setq dired-listing-switches "-lha"))
;; Switches are set before the hook is called, so we need to reload dired. The
;; dired-internal-noselect is a lower level function, so it is faster. WARNING:
;; Not sure if it is equivalent though.
; (dired dired-directory dired-listing-switches)
(dired-internal-noselect dired-directory dired-listing-switches)
(setq wdired-allow-to-change-permissions t)
(require 'dired-x)
(setq dired-omit-files "^\\.")
;; omit-mode needs to be start _after_ omit-files redefinition.
(dired-omit-mode)
(require 'tool-pdf) ; for `pdf-viewer'
(setq dired-guess-shell-alist-user
(list
'("\\.ogg$" "mpv")
'("\\.\\(jpe?g\\|png\\|git\\)$" "sxiv")
'("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv")
'("\\.pdf$" (concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))))
(defvar dired-showing-humansize t "If dired is displaying humansize or not.")
(defun dired-toggle-humansize ()
"Toggle displaying humansize in dired."
(interactive)
(let ((switch-regexp "\\(\\`\\| \\)-\\([a-gi-zA-Z]*\\)\\(h\\)\\([^ ]*\\)")
case-fold-search)
(while (string-match switch-regexp dired-actual-switches)
(if (and (equal (match-string 2 dired-actual-switches) "")
(equal (match-string 4 dired-actual-switches) ""))
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches))
(setq dired-actual-switches
(replace-match "" t t dired-actual-switches 3))))
(if dired-showing-humansize
(setq dired-showing-humansize nil)
(progn
(setq dired-actual-switches
(concat dired-actual-switches
(if (string-match-p "\\`-[[:alnum:]]+\\'"
dired-actual-switches)
"h" " -h")))
(setq dired-showing-humansize t))))
(revert-buffer))
(local-set-key (kbd "C-c a") 'dired-toggle-hidden)
(local-set-key (kbd "C-c h") 'dired-toggle-humansize)
(local-set-key (kbd "<left>") 'dired-up-directory)
(local-set-key (kbd "<right>") 'dired-find-file)
(local-set-key (kbd "SPC") 'dired-mark)
(local-set-key (kbd "<backspace>") 'dired-up-directory)
(local-set-key (kbd "b") 'dired-up-directory)
(provide 'mode-dired)

View File

@ -2,10 +2,6 @@
;; Graphviz' dot mode
;;==============================================================================
(autoload 'graphviz-dot-mode "graphviz-dot-mode.el" "Graphviz dot mode." t)
(add-to-list 'auto-mode-alist '("\\.dot\\'" . graphviz-dot-mode))
(setq graphviz-dot-preview-extension "pdf")
(defcustom graphviz-dot-view-extension "pdf"
"Graphviz format for external view."
@ -36,4 +32,4 @@ buffer is saved before the command is executed."
(downcase mode-name) nil cmd))
(message (format "Executing `%s'..." cmd))))))
(provide 'mode-dot)

11
.emacs.d/mode-ediff.el Normal file
View File

@ -0,0 +1,11 @@
;; Ediff in one frame.
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; Ediff split horizontally by default. ediff split does not seem to
;; work. Looks like the variable is never used in the source file.
(add-hook
'ediff-mode-hook
(lambda ()
(setq ediff-merge-split-window-function 'split-window-vertically)))
(provide 'mode-ediff)

37
.emacs.d/mode-eshell.el Normal file
View File

@ -0,0 +1,37 @@
;; Eshell
(setq eshell-directory-name (concat emacs-cache-folder "eshell"))
;; (setq eshell-aliases-file (concat user-emacs-directory "eshell-alias"))
;; TODO: this breaks eshell completion and history.
;; (setq eshell-prompt-function
;; (lambda nil
;; (let ((path (abbreviate-file-name (eshell/pwd))))
;; (concat ".-(" path ")"
;; (make-string (- (window-body-width) 5 (length path)) ?-)
;; "\n`--"
;; (if (= (user-uid) 0) "# " "> ")))))
(nconc eshell-visual-commands
'("abook" "cmus" "htop" "mutt" "ncdu" "newsbeuter" "ranger"
"rtorrent" "task" "tig"))
(when (file-executable-p "/usr/bin/pacman")
(map-on-pair 'eshell/alias
'(("pc" "sudo pacman -Sc")
("pi" "sudo pacman -S --needed")
("pqi" "pacman -Qi")
("pqo" "pacman -Qo")
("pqs" "pacman -Qs")
("pr" "sudo pacman -Rs")
("psi" "pacman -Si")
("pss" "pacman -Ss")
("pu" "sudo pacman -Syu"))))
(map-on-pair 'eshell/alias
'(("mkdir" "mkdir -p")
("lx" "ls -lXh")
("lx" "ls -lXh")
("lk" "ls -lSrh")
("lc" "ls -lrc")
("ll" "ls -hl")
("la" "ls -ahl")))
(provide 'mode-eshell)

46
.emacs.d/mode-gud.el Normal file
View File

@ -0,0 +1,46 @@
;; Set GUD to display many windows by default.
;; (setq gdb-show-main t)
(setq gdb-many-windows t)
;; Change GUD many-windows layout.
(defun gdb-setup-windows ()
"Layout the window pattern for `gdb-many-windows'."
(setq gdb-source-window (selected-window))
(gdb-display-locals-buffer)
(delete-other-windows)
(gdb-display-stack-buffer)
(delete-other-windows)
(gdb-display-breakpoints-buffer)
(delete-other-windows)
;; TODO: this does not behave the same on Emacs 23 and 24.
(switch-to-buffer
(if gud-last-last-frame
(gud-find-file (car gud-last-last-frame))
(if gdb-main-file
(gud-find-file gdb-main-file)
;; Put buffer list in window if we can't find a source file.
(list-buffers-noselect))))
(split-window-horizontally)
(other-window 1)
(split-window nil ( / ( * (window-height) 3) 4))
(split-window nil ( / (window-height) 3))
(gdb-set-window-buffer (gdb-locals-buffer-name))
(other-window 1)
(gdb-set-window-buffer gud-comint-buffer)
(when (and
(boundp 'gdb-use-separate-io-buffer)
gdb-use-separate-io-buffer)
(split-window-horizontally)
(other-window 1)
(gdb-set-window-buffer
(gdb-get-buffer-create 'gdb-inferior-io)))
(other-window 1)
(gdb-set-window-buffer (gdb-stack-buffer-name))
(split-window-horizontally)
(other-window 1)
(gdb-set-window-buffer (gdb-breakpoints-buffer-name))
(other-window 1))
(provide 'mode-gud)

396
.emacs.d/mode-latex.el Normal file
View File

@ -0,0 +1,396 @@
;;==============================================================================
;; LaTeX, using the TeX setup
;;==============================================================================
(require 'mode-tex)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Functions
(defun latex-itemize ()
"Prepend \\item to the beginning of the line if not already
there, otherwise insert it on next line. On region, append
\item to every line and surround the region by an `itemize'
environment. If bound to M-RET, you can then easily apply this
command on the paragraph at point with M-h M-RET."
(interactive)
(let (min max case-fold-search)
(if (not (region-active-p))
(if (string-match "\\item" (buffer-substring (line-beginning-position) (line-end-position)))
(progn
(goto-char (line-end-position))
(newline)
(insert "\\item "))
(goto-char (line-beginning-position))
(insert "\\item")
(just-one-space))
(replace-regexp "^ *\\([^
]\\)" "\\\\item \\1" nil (region-beginning) (region-end))
(goto-char (region-end))
(goto-char (line-end-position))
(newline)
(insert "\\end{itemize}")
(goto-char (region-beginning))
(goto-char (line-beginning-position))
(insert "\\begin{itemize}")
(newline))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LaTeX setup
(setq latex-block-default "itemize")
(setq latex-block-names '("listing" "align" "align*" "Bmatrix" "Vmatrix" "bmatrix" "matrix" "pmatrix" "smallmatrix" "vmatrix"))
(mapcar
(lambda (latex-block)
(add-to-list 'latex-block-body-alist `(,latex-block nil '(delete-horizontal-space t) _)))
'("listing" "verbatim" "verbatim*"))
(add-hook-and-eval
'latex-mode-hook
(lambda ()
(set (make-local-variable 'tex-extension-list)
'("aux" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy"))
(set (make-local-variable 'tex-command) "pdflatex")
;; 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 a") 'latex-article)
(local-set-key (kbd "C-c C-a") 'latex-insert-table)
(local-set-key (kbd "C-c C-c") 'latex-smallcaps)
(local-set-key (kbd "C-c C-e") 'latex-emph)
(local-set-key (kbd "C-c C-l") 'latex-slanted)
(local-set-key (kbd "C-c C-o") 'latex-orgtbl)
(local-set-key (kbd "C-c C-s") 'latex-insert-section)
(local-set-key (kbd "C-c C-u") 'latex-superscript)
(local-set-key (kbd "C-c l") 'latex-lstinline)
(local-set-key (kbd "C-c u") 'latex-package)
(local-set-key (kbd "M-RET") 'latex-itemize)
(turn-on-orgtbl)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Skeletons
(define-skeleton latex-emph "Insert emph." nil "\\emph{" @ _ "}" @)
(define-skeleton latex-slanted "Insert slanted text." nil "\\textsl{" @ _ "}" @)
(define-skeleton latex-smallcaps "Insert smallcaps text." nil "\\textsc{" @ _ "}" @)
(define-skeleton latex-superscript "Insert supercript text." nil "\\textsuperscript{" @ _ "}" @)
(define-skeleton latex-package "Use package." "Package: " \n "\\usepackage[" @ "]{" @ _ "}" \n @)
(defvar latex-section-default "section")
(defvar latex-section-names
'("part" "part*" "chapter" "chapter*" "section*" "subsection" "subsection*"
"subsubsection" "subsubsection*" "paragraph" "paragraph*" "subparagraph" "subparagraph*")
"Standard LaTeX section names.")
(define-skeleton latex-insert-section
"Insert section at point.
Puts point to section title. Section are auto-completed from
`latex-section-names'."
(let ((choice (completing-read (format "LaTeX section name [%s]: "
latex-section-default)
latex-section-names
nil nil nil nil latex-section-default)))
(setq latex-section-default choice)
(unless (member choice latex-section-names)
;; Remember new block names for later completion.
(push choice latex-section-names))
choice)
\n "\\" str "{" @ _ "}" @)
(defvar latex-table-default "tabular")
(defvar latex-table-names
'("tabular" "tabu" "tabular*" "tabularx" "tabulary" "longtabu")
"Standard LaTeX table names.")
(define-skeleton latex-insert-table
"Create a table at point.
The table type is any value found in `latex-table-names'."
(let ((choice (completing-read (format "LaTeX table type [%s]: "
latex-table-default)
latex-table-names
nil nil nil nil latex-table-default)))
(setq latex-table-default choice)
(unless (member choice latex-table-names)
;; Remember new block names for later completion.
(push choice latex-table-names))
choice)
'(require 'functions)
\n "\\begin{center}" > \n
"\\begin{" str "}{"
'(setq v1 (skeleton-read "Format: " "ll"))
v1 "}" > \n
'(setq v2 (count-occurences "[a-z]" v1))
@ (mapconcat 'identity (split-string (make-string v2 ?&) "" t) " ") " \\\\" \n
@ _ "\\\\" \n
"\\end{" str "}" > \n
"\\end{center}" > \n @)
;; TODO: implement orgtbl directly with latex tables and remove this skel.
(define-skeleton latex-orgtbl
"Insert orgtbl skel."
"Table name: "
> "\\begin{center}" \n
"% BEGIN RECEIVE ORGTBL " str \n
"% END RECEIVE ORGTBL " str \n
"\\end{center}" > \n
"\\begin{comment}" \n
"#+ORGTBL: SEND " str " orgtbl-to-latex" \n
"| " @ _ " |" \n
"%$" \n
"\\end{comment}" > \n @)
(define-skeleton latex-minipage
"Insert skel."
"Width: "
> "\\begin{minipage}{" str "}" \n
@ _ \n
"\\end{minipage}" > \n @)
(define-skeleton latex-parbox
"Insert skel."
"Width: "
> "\\parbox{" str "}{" \n
@ _ \n
"}" > \n @)
(define-skeleton latex-lstinline
"Insert inline listing." nil
"\\lstinline @" @ _ "@" @)
(define-skeleton latex-graphics
"Insert centered picture."
nil
> "\\begin{center}" \n
"\\includegraphics[width=" @ (skeleton-read "Width: " "\\linewidth") "]{" @ _ "}" \n
"\\end{center}" > \n @)
(define-skeleton latex-article
"Insert article template."
nil
> "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\documentclass[10pt,a4paper]{article}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{lmodern}
\\usepackage{marvosym}
\\usepackage{textcomp}
\\DeclareUnicodeCharacter{20AC}{\\EUR{}}
\\DeclareUnicodeCharacter{2260}{\\neq}
\\DeclareUnicodeCharacter{2264}{\\leq}
\\DeclareUnicodeCharacter{2265}{\\geq}
\\DeclareUnicodeCharacter{22C5}{\\cdot}
\\DeclareUnicodeCharacter{A0}{~}
\\DeclareUnicodeCharacter{B1}{\\pm}
\\DeclareUnicodeCharacter{D7}{\\times}
%%=============================================================================
%% Packages
\\usepackage{amsmath,amssymb,amsfonts}
% \\usepackage{comment}
\\usepackage{geometry}
% \\usepackage{lipsum}
% \\usepackage{needspace}
\\usepackage{xspace}
%%=============================================================================
%% Properties
\\title{" @ (skeleton-read "Title: " "Title") "}
\\author{" @ (skeleton-read "Author: " "P.~\\textsc{Neidhardt}") "}
\\makeatletter
\\let\\thetitle\\@title
\\let\\theauthor\\@author
\\let\\thedate\\@date
\\makeatother" \n
'(setq latex-setup-list '(latex-preamble-aliases latex-preamble-formatting latex-preamble-tables latex-preamble-graphics latex-preamble-listing))
'(while (and latex-setup-list
(= (read-key (concat "Insert " (symbol-name (car latex-setup-list)) "? (y)")) ?y))
(newline-and-indent)
(funcall (pop latex-setup-list))
(newline-and-indent))
\n
"%%=============================================================================
%% Babel (load last before 'hyperref')
\\usepackage[french,ngerman,english]{babel}
\\iflanguage{french}{
}{
%% Narrow items
\\newlength{\\wideitemsep}
\\setlength{\\wideitemsep}{.5\\itemsep}
\\addtolength{\\wideitemsep}{-7pt}
\\let\\olditem\\item
\\renewcommand{\\item}{\\setlength{\\itemsep}{\\wideitemsep}\\olditem}
}
%%==============================================================================
%% Hyperref (load last)
\\usepackage[]{hyperref}
\\hypersetup{
colorlinks=true,
linkcolor=DarkRed,
linktoc=page,
urlcolor=blue,
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\maketitle
% \\vfill
% \\thispagestyle{empty}
% \\tableofcontents
" \n
> @ _ \n \n
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" \n)
(define-skeleton latex-preamble-aliases
"Insert setup template."
nil
> "%%=============================================================================
%% Aliases
\\let\\latexbak\\LaTeX
\\renewcommand{\\LaTeX}{\\textrm{\\latexbak}\\xspace}
\\let\\texbak\\TeX
\\renewcommand{\\TeX}{\\textrm{\\texbak}\\xspace}
\\def\\unix{\\textsc{Unix}\\xspace}
\\def\\ie{\\textsl{i.e.}\\xspace}
\\def\\eg{\\textsl{e.g.}\\xspace}" \n)
(define-skeleton latex-preamble-formatting
"Insert setup template."
nil
> "%%=============================================================================
%% Formatting
% \\usepackage{parskip}
% \\setlength{\\parindent}{15pt}
% \\renewcommand{\\thefigure}{\\arabic{section}.\\arabic{figure}}
\\renewcommand{\\arraystretch}{1.4}
% \\renewcommand{\\familydefault}{\\sfdefault}
%% Header
% \\usepackage{fancyhdr}
% \\setlength{\\headheight}{15.2pt}
% \\pagestyle{fancy}
% \\lhead{\\thetitle}
% \\rhead{\\theauthor}" \n)
(define-skeleton latex-preamble-tables
"Insert setup template."
nil
> "%%==============================================================================
%% Tables
\\usepackage{longtable}
\\usepackage{tabu}" \n)
(define-skeleton latex-preamble-graphics
"Insert setup template."
nil
> "%%==============================================================================
%% Graphics
%% Load TikZ after xcolor.
\\usepackage[svgnames]{xcolor}
\\usepackage{graphicx}
\\usepackage{tikz}
\\newcommand{\\fancybox}[1]{
\\begin{tikzpicture}
\\node[draw,rounded corners]{#1};
\\end{tikzpicture}
}" \n)
(define-skeleton latex-preamble-listing
"Insert listing setup template."
;; WARNING: we need to put a '-' at the very end so that the cursor will end
;; there. Otherwise it will be placed at the beginning. This is due to some
;; unicode or escape characters in the literate array, which `skeleton-insert'
;; does not seem to parse correctly.
nil
> "%%=============================================================================
%% Listings
\\usepackage{listings}
%% Source code.
\\lstdefinestyle{custom}{
% numbers=left,
belowcaptionskip=1\\baselineskip,
breaklines=true,
frame=L,
xleftmargin=\\parindent,
% framexleftmargin=\\parindent,
language=C,
showstringspaces=false,
basicstyle=\\footnotesize\\ttfamily,
keywordstyle=\\bfseries\\color{green!40!black},
commentstyle=\\itshape\\color{purple!40!black},
identifierstyle=\\color{blue},
stringstyle=\\color{orange},
numberstyle=\\ttfamily,
}
\\lstset{escapechar=,style=custom,
literate=
{á}{{\\'a}}1 {é}{{\\'e}}1 {í}{{\\'i}}1 {ó}{{\\'o}}1 {ú}{{\\'u}}1
{Á}{{\\'A}}1 {É}{{\\'E}}1 {Í}{{\\'I}}1 {Ó}{{\\'O}}1 {Ú}{{\\'U}}1
{à}{{\\`a}}1 {è}{{\\'e}}1 {ì}{{\\`i}}1 {ò}{{\\`o}}1 {ù}{{\\`u}}1
{À}{{\\`A}}1 {È}{{\\'E}}1 {Ì}{{\\`I}}1 {Ò}{{\\`O}}1 {Ù}{{\\`U}}1
{ä}{{\\\"a}}1 {ë}{{\\\"e}}1 {ï}{{\\\"i}}1 {ö}{{\\\"o}}1 {ü}{{\\\"u}}1
{Ä}{{\\\"A}}1 {Ë}{{\\\"E}}1 {Ï}{{\\\"I}}1 {Ö}{{\\\"O}}1 {Ü}{{\\\"U}}1
{â}{{\\^a}}1 {ê}{{\\^e}}1 {î}{{\\^i}}1 {ô}{{\\^o}}1 {û}{{\\^u}}1
{Â}{{\\^A}}1 {Ê}{{\\^E}}1 {Î}{{\\^I}}1 {Ô}{{\\^O}}1 {Û}{{\\^U}}1
{œ}{{\\oe}}1 {Œ}{{\\OE}}1 {æ}{{\\ae}}1 {Æ}{{\\AE}}1 {ß}{{\\ss}}1
{ç}{{\\c c}}1 {Ç}{{\\c C}}1 {ø}{{\\o}}1 {å}{{\\r a}}1 {Å}{{\\r A}}1
{}{{\\EUR}}1 {£}{{\\pounds}}1
}
\\newcommand{\\includecode}[2][custom]{
\\lstinputlisting[caption=#2, escapechar=, style=#1]{#2}}" \n -)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The magnificent latex-math-preview mode!
;; TODO: some symbols are not generated properly.
(autoload 'latex-math-preview-expression "latex-math-preview" nil t)
(autoload 'latex-math-preview-insert-symbol "latex-math-preview" nil t)
(autoload 'latex-math-preview-save-image-file "latex-math-preview" nil t)
(autoload 'latex-math-preview-beamer-frame "latex-math-preview" nil t)
(autoload 'latex-math-preview-text-symbol-datasets "latex-math-preview" nil t)
(setq latex-math-preview-cache-directory-for-insertion
(concat emacs-cache-folder "latex-math-preview-cache"))
;; Extra for latex-math-preview-mode.
;; TODO: latex-math-preview-mode extra does not work.
(require 'latex-math-preview-extra-data nil t)
(add-hook
'latex-mode-hook
(lambda ()
;; (local-set-key (kbd "C-c p") 'latex-math-preview-expression)
;; (local-set-key (kbd "C-c C-p") 'latex-math-preview-save-image-file)
(local-set-key (kbd "C-c j") 'latex-math-preview-insert-symbol)
(local-set-key (kbd "C-c C-j") 'latex-math-preview-last-symbol-again)
;; (local-set-key (kbd "C-c C-b") 'latex-math-preview-beamer-frame)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-textcomp-symbol-data)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-pifont-zapf-dingbats-symbol-data)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-pifont-symbol-fonts-symbol-data)))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'mode-latex)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

10
.emacs.d/mode-lua.el Normal file
View File

@ -0,0 +1,10 @@
;;==============================================================================
;; Lua
;;==============================================================================
(add-hook-and-eval
'lua-mode-hook
(lambda ()
(set (make-local-variable 'compile-command) (concat "lua " buffer-file-name))))
(provide 'mode-lua)

69
.emacs.d/mode-makefile.el Normal file
View File

@ -0,0 +1,69 @@
;; makefile mode setup
(define-skeleton makefile-main
"Insert skel."
"App name: "
"## " str "
include config.mk
## Properties.
APPNAME = \"" str "\"
BIN = " (downcase str) "
VERSION = U
AUTHOR = \"Pierre Neidhardt\"
MANPAGE = \"NONE\"
MANSECTION = \"1\"
MAIL = \"<ambrevar@gmail.com>\"
YEAR = \"" (format-time-string "%Y") "\"
## Resources.
DEPS =
SRC += " str ".c
OBJ = ${SRC:.c=.o}
## Appends user flags.
CFLAGS_ALL += ${CFLAGS}
LDFLAGS_ALL += ${LDFLAGS}
## Application information.
CFLAGS_ALL += -DAPPNAME=\\\"${APPNAME}\\\"
CFLAGS_ALL += -DVERSION=\\\"${VERSION}\\\"
CFLAGS_ALL += -DAUTHOR=\\\"${AUTHOR}\\\"
CFLAGS_ALL += -DYEAR=\\\"${YEAR}\\\"
CFLAGS_ALL += -DMANPAGE=\\\"${MANPAGE}\\(${MANSECTION}\\)\\\"
## Compiler options.
CFLAGS_ALL += -Wall -Wextra -Wshadow -Winline -pedantic -std=c11
## Standard compliance options.
CFLAGS_ALL += -D_XOPEN_SOURCE=700 ## For use of getopt() with -pedantic.
## Dependencies
CFLAGS_ALL += $$(pkg-config --cflags ${DEPS})
LDFLAGS_ALL += $$(pkg-config --libs ${DEPS})
################################################################################
## Rules
all: options ${BIN}
options:
@echo ${BIN} build options:
@echo \"CC = ${CC}\"
@echo \"CFLAGS = ${CFLAGS_ALL}\"
@echo \"LDFLAGS = ${LDFLAGS_ALL}\"
${BIN}: ${OBJ}
@${CC} ${LDFLAGS_ALL} $^ -o $@
%.o: %.c
@${CC} ${CFLAGS_ALL} $< -c -o $@
clean:
@rm ${BIN} ${OBJ}
.PHONY=all options clean" > \n)
(provide 'mode-makefile)
;; end of file

View File

@ -2,31 +2,76 @@
;; MediaWiki
;;==============================================================================
(when (require 'mediawiki nil t)
(setq
mediawiki-site-alist
'(
("Wikipedia" "http://en.wikipedia.org/w/" "Ambrevar" "" "Main Page")
("Wikibooks" "http://en.wikibooks.org/w/" "Ambrevar" "" "LaTeX")
("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Mutt")
("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page")
))
(setq mediawiki-site-alist
'(
("Wikipedia" "http://en.wikipedia.org/w/" "Ambrevar" "" "Main Page")
("Wikibooks" "http://en.wikibooks.org/w/" "Ambrevar" "" "LaTeX")
("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Mutt")
("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page")
))
;; The url-cookie timer is set to a high value because it seems that once the
;; cookie has been saved, MediaWiki fails to upload files correctly. Is
;; 'url-do-setup' needed to make sure the url-cookie-save-interval variable is
;; taken into account?
;; TODO: url-cookie timer does not work.
(setq url-cookie-save-interval 86400)
;; The url-cookie timer is set to a high value because it seems that once the
;; cookie has been saved, MediaWiki fails to upload files correctly. Is
;; 'url-do-setup' needed to make sure the url-cookie-save-interval variable is
;; taken into account?
;; TODO: url-cookie timer does not work.
(setq url-cookie-save-interval 86400)
(add-hook-and-eval
'mediawiki-mode-hook
(lambda ()
(visual-line-mode 1)
(turn-off-auto-fill)
(define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)
(local-unset-key (kbd "M-g"))
(local-set-key (kbd "C-c C-d") 'duplicate-line)
(local-set-key (kbd "C-c C-s") 'mediawiki-save)
(local-set-key (kbd "C-x C-s") 'save-buffer)
))
(setq mediawiki-mode-hook
(lambda ()
(visual-line-mode 1)
(turn-off-auto-fill)
(define-key mediawiki-mode-map (kbd "C-c RET") 'mediawiki-open-page-at-point)
(define-key mediawiki-mode-map (kbd "C-c o") 'mediawiki-browse)
(local-unset-key (kbd "M-g"))
(local-set-key (kbd "C-c C-d") 'duplicate-line)
(local-set-key (kbd "C-c C-s") 'mediawiki-save)
(local-set-key (kbd "C-x C-s") 'save-buffer)
)) )
;;==============================================================================
;; Skel
;;==============================================================================
(define-skeleton mediawiki-latex-link
"Insert link to the LaTeX wikibook."
"Link: " "[[LaTeX/" @ str "|" str "]]" _)
(define-skeleton mediawiki-latex-env
"Insert LaTeX environment."
nil "{{LaTeX/Environment|" @ _ "}}")
(define-skeleton mediawiki-latex-example
"Insert LaTeX example."
"Code: "
\n "{{LaTeX/Example|code=" @ str \n
"|render=" \n
_ \n
"}}" \n)
(define-skeleton mediawiki-latex-param
"Insert LaTeX parameter."
nil "{{LaTeX/Parameter|" @ _ "}}")
(define-skeleton mediawiki-latex-package
"Insert LaTeX package."
"{{LaTeX/Package|" @ _ "}}")
(define-skeleton mediawiki-latex-usage
"Insert LaTeX usage block."
nil "{{LaTeX/Usage|code=" \n
@ _ \n
"}}")
(define-skeleton mediawiki-latex-inline
"Insert LaTeX inline code."
nil "{{LaTeX/LaTeX|code=" @ _ "<!---->}}")
(define-skeleton mediawiki-tt
"Insert truetype text."
nil "<tt>" @ _ "</tt>" @)
(provide 'mode-mediawiki)

11
.emacs.d/mode-octave.el Normal file
View File

@ -0,0 +1,11 @@
;;==============================================================================
;; Octave
;;==============================================================================
;; Set comments to be '%' to be matlab-compatible.
(add-hook
'octave-mode-hook
(lambda ()
(set (make-local-variable 'comment-start) "% ")))
(provide 'mode-octave)

22
.emacs.d/mode-org.el Normal file
View File

@ -0,0 +1,22 @@
;; Org mode config.
;; Move annoying babel folder. This move does not seem to work properly.
(setq org-babel-temporary-directory (concat emacs-cache-folder "babel"))
;; Disable line splitting on M-RET
(setq org-M-RET-may-split-line '((default)))
(setq org-agenda-files '("~/todo.org"))
(setq org-enforce-todo-dependencies t)
;; Set PDF association in Org-mode (was Evince by default).
(eval-after-load "org"
'(progn
(require 'tool-pdf)
;; Change .pdf association directly within the alist
(setcdr (assoc "\\.pdf\\'" org-file-apps)
(concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))))
(add-hook
'org-mode-hook
(lambda ()
(auto-fill-mode -1)))
(provide 'mode-org)

10
.emacs.d/mode-perl.el Normal file
View File

@ -0,0 +1,10 @@
;;==============================================================================
;; Perl
;;==============================================================================
(add-hook-and-eval
'perl-mode-hook
(lambda ()
(set (make-local-variable 'compile-command) (concat "perl " buffer-file-name))))
(provide 'mode-perl)

View File

@ -2,40 +2,34 @@
;; Python
;;==============================================================================
(defcustom python-interpreter nil
"Python interpreter. If value is nil, the shabang will be
checked, and if no shabang is present, `python' will be used."
:safe 'stringp)
(defun python-version ()
"Returns whether we're running Python 2 or 3 according to the
shebang. System `python' is assumed by default."
(let ((firstline (car (split-string (buffer-string) "\n" t))))
"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")))))
(t python-shell-interpreter)))))
(defun python-set-interpreter ()
"Use compile to run python programs."
(interactive)
(hack-local-variables)
(let ((py-interpreter
(if python-interpreter
python-interpreter
(python-version))))
(set (make-local-variable 'compile-command)
(concat py-interpreter " " buffer-file-name))))
(set (make-local-variable 'compile-command)
(concat (python-version) " " buffer-file-name)))
(add-hook
(add-hook-and-eval
'python-mode-hook
(lambda ()
(set (make-local-variable 'compilation-scroll-output) t)
(python-set-interpreter)))
(add-hook 'compilation-before-hook 'python-set-interpreter nil t)))
;; Doc lookup. Requires the python.info file to be installed. See
;; https://bitbucket.org/jonwaltman/pydoc-info/.
(add-to-list 'load-path "~/path/to/pydoc-info")
(require 'pydoc-info nil t)
;; (add-to-list 'load-path "~/path/to/pydoc-info")
;; (require 'pydoc-info nil t)
(provide 'mode-python)

152
.emacs.d/mode-sh.el Normal file
View File

@ -0,0 +1,152 @@
;;==============================================================================
;; Shell
;;==============================================================================
(setq sh-indent-comment t)
(set (make-local-variable 'sh-shell-file) "/bin/sh") ; Useful for the first time this hook is loaded.
(setq-default sh-shell-file sh-shell-file)
;; (setq-default sh-shell 'sh)
(defun sh-set-interpreter ()
"Set shell interpreter.
Set `sh-shell', `sh-shell-file' and `compile-command' according to the following rules:
- Look at shabang.
- If file has no name, use default value of sh-shell-file.
- Check extension or file name.
- If none of the above yields a result, use default value of
sh-shell-file.
The advantages of this function over the vanilla code are:
- You can change default value of sh-shell-file in sh-mode-hook
and it will be used subsequently.
- Zsh is supported
- compile-command is set.
- Once sh-shell is set, sh-shell-file is changed accordingly. In
default Emacs, sh-shell-file is always the same."
(interactive)
(sh-set-shell
(cond ((save-excursion
(goto-char (point-min))
(looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)"))
(match-string 2))
((not buffer-file-name) sh-shell-file)
;; Checks that use `buffer-file-name' follow.
((string-match "\\.m?spec\\'" buffer-file-name) "rpm")
((string-match "[.]bash\\>" buffer-file-name) "bash")
((string-match "[.]csh\\>" buffer-file-name) "csh")
((string-match "[.]ksh\\>" buffer-file-name) "ksh")
((string-match "[.]sh\\>" buffer-file-name) "sh")
((string-match "[.]zsh\\>" buffer-file-name) "zsh")
((equal (file-name-nondirectory buffer-file-name) ".profile") "sh")
(t sh-shell-file))
nil nil)
;; Universal version.
; (setq sh-shell-file (executable-find (symbol-name sh-shell)))
;; Convenient version.
(setq sh-shell-file (concat "/bin/" (symbol-name sh-shell)))
(set (make-local-variable 'compile-command) (concat sh-shell-file " " buffer-file-name)))
(add-hook-and-eval
'sh-mode-hook
(lambda ()
(set (make-local-variable 'defun-prompt-regexp)
(concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)"))
(sh-set-interpreter)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-skeleton sh-check
"Insert a function checking for presence in PATH."
nil
"check()
{
for i ; do
if ! command -v $i >/dev/null 2>&1; then
echo \"'$i' not found in PATH. Exiting.\" >&2
exit 1
fi
done
}
")
(define-skeleton sh-command
"Insert a line that executes if command is found in path."
"Command name: "
> "command -v " @ str " >/dev/null 2>&1 && " @ _)
(define-skeleton sh-command-or-die
"Insert a line that quits if command is not found in path."
"Command name: "
> "if ! command -v " @ str " >/dev/null 2>&1; then" \n
> "echo '" str " not found in PATH. Exiting.' >&2" \n
> "exit 1" \n
"fi" > \n)
(define-skeleton sh-for
"Insert a for loop. See `sh-feature'. This overrides vanilla function."
"Index variable: "
> "for " str | "i"
'(setq v1 (skeleton-read "Index values: " ""))
(unless (string= v1 "")
(concat " in " v1))
"; do" \n
> _ \n
"done" > \n)
(define-skeleton sh-ifcommand
"Insert a test to check if command is found in path."
"Command name: "
> "if command -v " @ str " >/dev/null 2>&1; then" \n
> @ _ \n
"fi" > \n)
(define-skeleton sh-redirect-to-null
"Insert a null redirection."
nil
">/dev/null 2>&1")
(define-skeleton sh-while-getopts
"Insert a getops prototype."
"optstring: "
> "usage ()
{
cat<<EOF
Usage: ${1##*/} [OPTIONS] FILES
Options:
-h: Show this help.
EOF
}" \n
\n
> "while getopts :" str " OPT; do" \n
> "case $OPT in" \n
'(setq v1 (append (vconcat str) nil))
( (prog1 (if v1 (char-to-string (car v1)))
(if (eq (nth 1 v1) ?:)
(setq v1 (nthcdr 2 v1)
v2 "\"$OPTARG\"")
(setq v1 (cdr v1)
v2 nil)))
> str ")" \n
> _ v2 " ;;" \n)
> "?)" \n
> "usage \"$0\"" \n
"exit 1 ;;" > \n
"esac" > \n
"done" > \n \n
"shift $(($OPTIND - 1))" \n
"if [ $# -eq 0 ]; then
usage \"$0\"
exit 1
fi" \n)
(define-skeleton sh-while-read
"Insert a while read loop."
nil
> "while IFS= read -r i; do" \n
> @ _ \n
> "done <<EOF" \n
> "EOF" \n)
(provide 'mode-sh)

View File

@ -1,28 +0,0 @@
;;==============================================================================
;; Shell
;;==============================================================================
;; Allow comment indentation.
(setq sh-indent-comment t)
(setq sh-shell-file "/bin/sh")
(defun shell-set-interpreter ()
"If a shabang is present, use it as the shell interpreter,
otherwise use 'sh-shell-file'."
"Use compile to run python programs."
(interactive)
(hack-local-variables)
(let ((firstline (car (split-string (buffer-string) "\n" t))))
(let ((sh-interpreter
(if (not (string-match "^#!" firstline))
sh-shell-file
(substring firstline 2))))
(set (make-local-variable 'compile-command)
(concat sh-interpreter " " buffer-file-name)))))
(add-hook
'sh-mode-hook
(lambda ()
(shell-set-interpreter)))

View File

@ -1,296 +1,160 @@
;;==============================================================================
;; TeX and LaTeX
;; TeX
;;==============================================================================
;; The default tex-mode and AucTeX may seem quite disappointing. Let's use
;; custom KISS functions for everything.
;; Interesting options for the tex compiler:
;; * -file-line-error-style: change the style of error report to
;; display file name and line first.
;; * -halt-on-error: default.
;; * -interaction <mode>: like -halt-on-error, you can set the way
;; the compilers behave on errors. Possible values for <mode> are
;; 'batchmode', 'errorstopmode', 'nonstopmode' and 'scrollmode'.
;; * -shell-escape: allow the use of \write18{<external command>}
;; from within TeX documents. This is a potential security issue.
;; * -synctex=1: enable SyncTeX support.
;; You may use file local variable for convenience:
;; % -*- tex-start-options: \"-shell-escape\"
;; Note that -shell-escape can also be toggled with universal
;; argument.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CUSTOM
(defcustom tex-compiler nil
"This is the name of the executable called upon TeX compilations.
Examples: pdftex, pdflatex, xetex, xelatex, luatex, lualatex...
If value is nil, the compiler will be tex-default-compiler for
TeX mode, and latex-default-compiler for LaTeX mode."
:safe 'stringp)
(defcustom masterfile nil
"The file that should be compiled. Useful for modular documents."
:safe 'stringp)
(defcustom tex-compiler-options "-file-line-error-style -interaction nonstopmode -synctex=1"
"The options to the tex compiler. Options are set between the
compiler name and the file name.
Interesting options:
* -file-line-error-style: change the style of error report to
display file name and line first.
* -halt-on-error: default.
* -interaction <mode>: like -halt-on-error, you can set the way
the compilers behave on errors. Possible values for <mode> are
'batchmode', 'errorstopmode', 'nonstopmode' and 'scrollmode'.
* -shell-escape: allow the use of \write18{<external command>}
from within TeX documents. This is a potential security issue.
* -synctex=1: enable SyncTeX support.
You may use file local variable for convenience:
% -*- tex-compiler-options: \"-shell-escape\"
Note that -shell-escape can also be toggled with universal
argument."
:safe 'stringp)
(defcustom tex-startcommands ""
"You can call a TeX compiler upon a string instead of a file.
This is actually useful if you want to customize your
compilation.
If this variable is not an empty string, the mandatory \" is
prepended and \\input\" is appended, so that the target file gets
read; otherwise the TeX compiler would stop there.
You may use it to act on the process, like the default behaviour:
\\nonstopmode
which will continue the process whenever an error is
encountered. There is an command-line argument for that on most
compilers, that is is rarely useful.
If you use a color theme, or any conditional variable inside your
document, you may define it here:
\\def\\myvar{mycontent}"
:safe 'stringp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VARIABLES
(defvar tex-viewer "zathura --fork -s -x \"emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"'\"'\"%{input}\"'\"'\")) (goto-line %{line}))'\""
"PDF Viewer for TeX documents. You may want to fork the viewer
so that it detects when the same document is launched twice, and
persists when Emacs gets closed.
Simple command:
zathura --fork
We can use
emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'
to reverse-search a pdf using SyncTeX. Note that the quotes and
double-quotes matter and must be escaped appropriately.")
(defvar tex-default-compiler "pdftex"
"Default compiler for TeX mode. Used if tex-compiler is
empty.")
(defvar latex-default-compiler "pdflatex"
"Default compiler for LaTeX mode. Used if tex-compiler is
empty.")
(defvar tex-extension-list
'("aux" "glg" "glo" "gls" "idx" "ilg" "ind" "lof" "log" "nav" "out" "snm" "synctex" "synctex.gz" "tns" "toc" "xdy")
"List of known TeX exentsions. This list is used by 'tex-clean
(defvar 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"
"The TeX index file generator.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FUNCTIONS
(defun tex-set-compiler ()
"Use compile to process your TeX-based document. Use a prefix
argument to call the compiler along the '-shell-escape'
option. This will enable the use of '\write18{<external
command>}' from within TeX documents, which need to allow
external application to be called from TeX.
This may be useful for some features like GnuPlot support with TikZ.
WARNING: the -shell-escape option is a potential security issue."
"Set `compile-command' for TeX-based document."
(interactive)
(hack-local-variables)
(let (
;; Set compiler to be tex-compiler if not empty, or a default
;; compiler otherwise.
(local-compiler
(if (not tex-compiler)
(cond
((string= "latex-mode" major-mode) latex-default-compiler)
((string= "plain-tex-mode" major-mode) tex-default-compiler)
(t (message "Warning: unknown major mode. Trying pdftex.") "pdftex"))
tex-compiler))
;; Master file.
(local-master
(if (not masterfile) buffer-file-name masterfile))
;; If tex-startcommands has some content, we make sure it is a string
;; that loads the file.
(local-start-cmd
(if (not (string= "" tex-startcommands))
(concat "\"" tex-startcommands "\\input\"")))
;; Support of prefix argument to toggle -shell-escape.
(local-shell-escape
(if (equal current-prefix-arg '(4)) "-shell-escape" "")))
(let* (;; Master file.
(local-master
(if masterfile 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.
(idxfile ))
(set (make-local-variable 'compile-command)
(concat local-compiler " " local-shell-escape " " tex-compiler-options " " local-start-cmd " \"" local-master "\""))))
(concat
"cd " (if dirname dirname ".") " && "
(when (executable-find tex-index-command)
(concat tex-index-command " " (concat basename ".idx" ) " ; "))
(when (executable-find tex-bibtex-command)
(concat tex-bibtex-command " " basename " ; "))
tex-command
" " tex-start-options
" " tex-start-commands
" " (shell-quote-argument basename)))))
(defun tex-clean ()
"Remove all TeX temporary files. This command should be safe,
but there is no warranty."
(interactive)
(hack-local-variables)
(let (
;; Master file.
(local-master
(if (not masterfile) buffer-file-name masterfile)))
(let (
;; File name without extension.
(file
(replace-regexp-in-string "tex" "" (file-name-nondirectory local-master))))
;; Concatate file name to list.
(mapcar
;; Delete file if exist
(lambda (argfile) (interactive)
(when (and (file-exists-p argfile) (file-writable-p argfile))
(delete-file argfile)
(message "[%s] deleted." argfile)))
(mapcar
;; Concat file name with extensions.
(lambda (arg) (interactive) (concat file arg))
tex-extension-list)))))
(let ((master (concat
(if masterfile
(file-name-sans-extension masterfile)
(file-name-sans-extension buffer-file-name))
".")))
(mapcar
;; Delete file if it exists.
(lambda (argfile)
(when (and (file-exists-p argfile) (file-writable-p argfile))
(delete-file argfile)
(message "[%s] deleted." argfile)))
(mapcar
;; Concat file name with extensions.
(lambda (arg) (concat master arg))
tex-extension-list))))
(defun tex-pdf-compress ()
"PDF compressions might really strip down the PDF size. The
compression depends on the fonts used. Do not use this command if
your document embeds raster graphics."
"Use `masterfile' variable as default value for `pdf-compress'."
(interactive)
(require 'tool-pdf)
(hack-local-variables)
(let (
;; Master file.
(local-master
(if (not masterfile) buffer-file-name masterfile)))
(let (
;; Temp compressed file.
(file-temp
(concat (make-temp-name (concat "/tmp/" (file-name-nondirectory local-master))) ".pdf"))
;; File name with PDF extension.
(file
(replace-regexp-in-string "tex" "pdf" (file-name-nondirectory local-master))))
(when (and (file-exists-p file) (file-writable-p file))
(shell-command
(concat "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=\"" file-temp "\" \"" file "\""))
(rename-file file-temp file t)
))))
(let ((local-master (if masterfile masterfile buffer-file-name)))
(pdf-compress local-master)))
(defun tex-pdf-view ()
"Call a PDF viewer for current buffer file. File name should be
properly escaped with double-quotes in case it has spaces."
"Use `masterfile' variable as default value for `pdf-view'."
(interactive)
(require 'tool-pdf)
(hack-local-variables)
(let (
;; Master file.
(local-master
(if (not masterfile) buffer-file-name masterfile)))
(let ((local-master (if masterfile masterfile buffer-file-name)))
(pdf-view local-master)))
(shell-command
(concat tex-viewer
" \""
(replace-regexp-in-string "\.tex$" "\.pdf" (file-name-nondirectory local-master))
"\" &" ))
(delete-windows-on "*Async Shell Command*")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MACROS
(defun latex-itemize ()
"Prepend \\item to the beginning of the line if not already
there, otherwise insert it on next line. On region, append
\item to every line and surround the region by an `itemize'
environment. If bound to M-RET, you can then easily apply this
command on the paragraph at point with M-h M-RET."
(defun tex-toggle-escape-char ()
"Make backslash part of the word syntax or not.
This does not interfere with `subword-mode'."
(interactive)
(let (min max case-fold-search)
(if (not (region-active-p))
(if (string-match "\\item" (buffer-substring (line-beginning-position) (line-end-position)))
(progn
(goto-char (line-end-position))
(newline)
(insert "\\item "))
(goto-char (line-beginning-position))
(insert "\\item")
(just-one-space))
(replace-regexp "^ *\\([^
]\\)" "\\\\item \\1" nil (region-beginning) (region-end))
(goto-char (region-end))
(goto-char (line-end-position))
(newline)
(insert "\\end{itemize}")
(goto-char (region-beginning))
(goto-char (line-beginning-position))
(insert "\\begin{itemize}")
(newline))))
(if (equal (char-syntax ?\\) ?\\)
(progn
(modify-syntax-entry ?\\ "w")
(message "\\ is a not an escape character"))
(modify-syntax-entry ?\\ "\\")
(message "\\ is a an escape character")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOKS
;; TeX setup
(add-hook
(setq tex-start-options "-file-line-error-style -interaction=nonstopmode -synctex=1 ")
(setq tex-start-commands nil)
(add-hook-and-eval
'tex-mode-hook
(lambda ()
(dolist (key '("\C-c\C-f" "\C-c\C-b"))
(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-hide-window) 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)
(tex-set-compiler)))
(add-hook 'latex-mode-hook (lambda () (local-set-key (kbd "M-RET") 'latex-itemize)))
(add-hook 'latex-mode-hook 'turn-on-orgtbl)
(setq tex-command "pdftex")
(add-hook 'compilation-before-hook 'tex-set-compiler nil t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The magnificent latex-math-preview mode!
;; TODO: some symbols are not generated properly.
(autoload 'latex-math-preview-expression "latex-math-preview" nil t)
(autoload 'latex-math-preview-insert-symbol "latex-math-preview" nil t)
(autoload 'latex-math-preview-save-image-file "latex-math-preview" nil t)
(autoload 'latex-math-preview-beamer-frame "latex-math-preview" nil t)
(autoload 'latex-math-preview-text-symbol-datasets "latex-math-preview" nil t)
;; Skeletons
(setq latex-math-preview-cache-directory-for-insertion
(concat emacs-cache-folder "latex-math-preview-cache"))
(define-skeleton tex-array
"Insert skel."
"Format: "
"$$\\begin{array}{" @ str "}" \n
_ \n
"\\end{array}$$" > \n)
;; Extra for latex-math-preview-mode.
;; TODO: latex-math-preview-mode extra does not work.
(require 'latex-math-preview-extra-data nil t)
(add-hook
'latex-mode-hook
(lambda ()
;; (local-set-key (kbd "C-c p") 'latex-math-preview-expression)
;; (local-set-key (kbd "C-c C-p") 'latex-math-preview-save-image-file)
(local-set-key (kbd "C-c j") 'latex-math-preview-insert-symbol)
(local-set-key (kbd "C-c C-j") 'latex-math-preview-last-symbol-again)
;; (local-set-key (kbd "C-c C-b") 'latex-math-preview-beamer-frame)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-textcomp-symbol-data)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-pifont-zapf-dingbats-symbol-data)
;; (add-to-list 'latex-math-preview-text-symbol-datasets
;; latex-math-preview-pifont-symbol-fonts-symbol-data)))
))
(define-skeleton tex-bf "Insert skel." nil "{\\bf{" @ _ "}" @)
(define-skeleton tex-binom "Insert skel." nil "\\binom{" @ _ "}{" @ _ "}" @)
(define-skeleton tex-coprod "Insert skel." nil "\\coprod_{" @ _ "}^{" @ _ "}" @)
(define-skeleton tex-em "Insert skel." nil "{\\em{" @ _ "}" @)
(define-skeleton tex-footnote "Insert skel." nil "\\footnote{" @ _ "}" @)
(define-skeleton tex-href "Insert skel." "Desc: " "\\href{" @ _ "}{" @ str "}" @)
(define-skeleton tex-it "Insert skel." nil "{\\it{" @ _ "}" @)
(define-skeleton tex-main "Insert skel." nil
"\\input eplain" \n
@ > _ \n
"\\bye" > @)
(define-skeleton tex-prod "Insert skel." nil "\\prod_{" @ _ "}^{" @ _ "}" @)
(define-skeleton tex-sum "Insert skel." nil "\\sum_{" @ _ "}^{" @ _ "}" @)
(define-skeleton tex-tt "Insert skel." nil "{\\tt{" @ _ "}" @)
(define-skeleton tex-url "Insert skel." nil "\\url{" @ _ "}" @)
(provide 'mode-tex)

View File

@ -1,83 +1,12 @@
;;==============================================================================
;; Texinfo
;; Texinfo using TeX setup
;;==============================================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CUSTOM
(defcustom masterfile nil
"The file that should be compiled. Useful for modular documents."
:safe 'stringp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VARIABLE
(defvar texinfo-viewer "zathura --fork"
"PDF Viewer for Texinfo documents. You may want to fork the
viewer so that it detects when the same document is launched
twice, and persists when Emacs gets closed.")
(defvar texinfo-extension-list '("aux" "cp" "cps" "fn" "ky" "log" "pg" "toc" "tp" "vr" "vrs")
"List of known Texinfo exentsions. This list is used by
'texinfo-clean to purge all matching files.")
(require 'tex-mode)
(require 'mode-tex)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FUNCTIONS
(defun texinfo-set-compiler ()
"Use compile to process your Texinfo document."
(interactive)
(hack-local-variables)
(let
;; Master file
( (local-master (if (not masterfile) buffer-file-name masterfile)))
(set (make-local-variable 'compile-command)
(concat "texi2pdf -b \"" local-master "\""))))
(defun texinfo-clean ()
"Remove all Texinfo temporary files. This command should be safe,
but there is no warranty."
(interactive)
(hack-local-variables)
(let
;; Master file.
((local-master (if (not masterfile) buffer-file-name masterfile)))
(let
;; File name without extension.
((file
(replace-regexp-in-string "texi" "" (file-name-nondirectory local-master))))
;; Concatate file name to list.
(mapcar
;; Delete file if exist
(lambda (argfile) (interactive)
(when (and (file-exists-p argfile) (file-writable-p argfile))
(delete-file argfile)
(message "[%s] deleted." argfile)))
(mapcar
;; Concat file name with extensions.
(lambda (arg) (interactive) (concat file arg))
texinfo-extension-list)))))
(defun texinfo-pdf-view ()
"Call a PDF viewer for current buffer file. File name should be
properly escaped with double-quotes in case it has spaces."
(interactive)
(hack-local-variables)
(let
;; Master file.
((local-master (if (not masterfile) buffer-file-name masterfile)))
(shell-command
(concat texinfo-viewer
" \""
(replace-regexp-in-string "\.texi$" "\.pdf" (file-name-nondirectory local-master))
"\" &" ))
(delete-windows-on "*Async Shell Command*")))
(defun texinfo-menu-update ()
"Update texinfo node menu automatically."
(interactive)
@ -91,13 +20,15 @@ properly escaped with double-quotes in case it has spaces."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOKS
(add-hook
(add-hook-and-eval
'texinfo-mode-hook
(lambda ()
(setq fill-column 80)
(set (make-local-variable 'compilation-scroll-output) t)
(set (make-local-variable 'compilation-hide-window) t)
(set (make-local-variable 'use-hard-newlines) t)
(setq fill-column 80) ;; Really needed?
(local-set-key (kbd "C-c C-b") 'texinfo-menu-update)
(local-set-key (kbd "<f9>") 'texinfo-pdf-view)
(texinfo-set-compiler)))
(set (make-local-variable 'tex-extension-list)
'("aux" "cp" "cps" "fn" "ky" "log" "pg" "toc" "tp" "vr" "vrs"))
(set (make-local-variable 'tex-start-options) nil)
(set (make-local-variable 'tex-command) "texi2pdf -b")
(tex-set-compiler)))
(provide 'mode-texinfo)

View File

@ -4,3 +4,7 @@
(setq add-log-full-name "Pierre Neidhardt")
(setq add-log-mailing-address "ambrevar@gmail.com")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'personal)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,28 +0,0 @@
;; This configuration is in a seperate file so that we can choose to load it or
;;not.
;;==============================================================================
;;Yasnippet
;;==============================================================================
;;Yasnippet is slow when loading snippets from source. Generate a bundle
;;instead: yas/compile-bundle Besides you can convert the generated file to
;;bytecode.
;; (add-to-list 'load-path "~/.emacs.d/plugins")
;; (require 'yasnippet-bundle)
;; Next follows a traditional, yet not-optimized configuration for Yasnippet.
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/yas")
(when (require 'yasnippet nil t)
(setq yas-snippet-dirs "~/.emacs.d/snippets" )
(if (fboundp 'yas/initialize)
;; Old yasnippet versions.
(progn
(yas/initialize)
(set-face-background 'yas/field-highlight-face "#1a1a1a")
(yas/load-directory yas-snippet-dirs))
;; New yasnippet versions.
(progn
(yas-global-mode 1)
(yas-load-directory yas-snippet-dirs)) ) )

View File

@ -1 +0,0 @@
text-mode

View File

@ -1,7 +0,0 @@
# name: do { ... } while (...)
# key: do
# --
do
{
$0
} while (${1:condition})

View File

@ -1,7 +0,0 @@
# name: else { ... }
# key: else
# --
else
{
$0
}

View File

@ -1,7 +0,0 @@
# name: for (...; ...; ...) { ... }
# key: for
# --
for (${1:i = 1}; ${2:i <= NF}; ${3:i++})
{
$0
}

View File

@ -1,7 +0,0 @@
# name: for ( var in array ) statement
# key: forin
# --
for ( ${1:var} in ${2:array})
{
$0
}

View File

@ -1,6 +0,0 @@
#name : type fun (args) { ... }
# --
function ${1:name} (${2:args})
{
$0
}

View File

@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# key: gsub
# --
gsub ("${1:regex}" , "${2:subs}"${3:, s})

View File

@ -1,7 +0,0 @@
# name: if (...) { ... }
# key: if
# --
if (${1:condition})
{
$0
}

View File

@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: printf
# contributor: joaotavora
# key: printf
# --
printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\)")}$2${1:$(if (string-match "%" text) "\)" "")}

View File

@ -1,7 +0,0 @@
# name : while (...) { ... }
# key: while
# --
while (${1:condition})
{
$0
}

View File

@ -1 +0,0 @@
c-mode

View File

@ -1,16 +0,0 @@
# name: define DEBUG_CMD
# key: debug
# --
#ifdef DEBUG
#define DEBUG_CMD(CMD) do {CMD;} while(0)
#else
#define DEBUG_CMD(CMD) do {} while(0)
#endif
#define DEBUG_STR(STR) DEBUG_CMD(fprintf(stderr, ":: %s\n", STR))
#define DEBUG_PRINT(...) DEBUG_CMD ( \
fprintf(stderr, "\n\033[31;1mDEBUG:\033[0m %s:%d:%s()\t", __FILE__, __LINE__, __func__); \
fprintf(stderr, __VA_ARGS__);\
fprintf(stderr, "\n"); \
)

View File

@ -1,7 +0,0 @@
# name: do { ... } while (...)
# key: do
# --
do
{
$0
} while (${1:condition});

View File

@ -1,7 +0,0 @@
# name: else { ... }
# key: else
# --
else
{
$0
}

View File

@ -1,4 +0,0 @@
# name: FILE *fp = fopen(..., ...);
# key: fopen
# --
FILE *${fp} = fopen(${"file"}, "${r}");

View File

@ -1,7 +0,0 @@
# name: for (...; ...; ...) { ... }
# key: for
# --
for (${1:i = 0}; ${2:i < N}; ${3:i++})
{
$0
}

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: fprintf
# contributor : joaotavora, ambrevar
# key: fprintf
# --
fprintf ($1, "${2:%s}\\n"${2:$(if (string-match "%" text) ", " "\);")
}$3${2:$(if (string-match "%" text) "\);" "")}

View File

@ -1,7 +0,0 @@
#name : type fun (args) { ... }
# --
static ${1:void}
${2:name} (${3:void})
{
$0
}

View File

@ -1,7 +0,0 @@
# name: if (...) { ... }
# key: if
# --
if (${1:condition})
{
$0
}

View File

@ -1,4 +0,0 @@
# name: #include "..."
# key: inc
# --
#include "$1"

View File

@ -1,4 +0,0 @@
# name: #include <...>
# key: inc
# --
#include <$1>

View File

@ -1,50 +0,0 @@
# name: int loadfile (const char * path, char ** buffer_ptr)
# key: loadfile
# --
unsigned long loadfile (const char * path, char ** buffer_ptr)
{
#define MAX_FILESIZE 1073741824 /* One gigabyte */
/* Handle variable. */
char* buffer;
FILE* file = fopen(path, "rb");
if (file == NULL)
{
perror(path);
return 0;
}
fseek(file, 0, SEEK_END);
long length = ftell(file);
/* fprintf (stdout, "Note: file %s is %u bytes long.\n", path, length); */
if (length > MAX_FILESIZE)
{
fprintf (stderr, "%s size %ld is bigger than %d bytes.\n", path, length, MAX_FILESIZE);
fclose(file);
return 0;
}
fseek(file, 0, SEEK_SET);
buffer = (char*)malloc(length + 1);
if (buffer == NULL)
{
perror("malloc");
fclose(file);
return 0;
}
if(fread(buffer, 1, length, file) == 0)
{
fclose(file);
return 0;
}
buffer[length] = '\0';
fclose(file);
*buffer_ptr = buffer;
return length;
}

View File

@ -1,8 +0,0 @@
# name: int main(argc, argv) { ... }
# key: main
# --
int main(int argc, char** argv)
{
$0
return 0;
}

View File

@ -1,9 +0,0 @@
# name: #ifndef XXX; #define XXX; #endif
# key: once
# --
#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
#define $1
$0
#endif /* $1 */

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: printf
# contributor: joaotavora
# key: printf
# --
printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);")
}$2${1:$(if (string-match "%" text) "\);" "")}

View File

@ -1,7 +0,0 @@
# name: struct ... { ... }
# key: struct
# --
struct ${1:name}
{
$0
};

View File

@ -1,11 +0,0 @@
# name: switch (...) { ... }
# key: switch
# --
switch ($1)
{
case $2:
$0
break;
default:
break;
}

View File

@ -1,7 +0,0 @@
# name : while (...) { ... }
# key: while
# --
while (${1:condition})
{
$0
}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : abstract
# group: sections
# name : \abstract
# --
\begin{abstract}
$0
\end{abstract}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Pierre Neidhardt <ambrevar@gmail.com>
# key: align
# group: math
# name: \begin{align*} ... \end{align*}
# --
\begin{align*}
$1 &= $0 \\\\
\end{align*}

View File

@ -1,179 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com> 2012-10-14
# key: article
# group: skeleton
# name: full article template
# --
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{geometry}
\usepackage{lmodern}
\usepackage{marvosym}
\usepackage{textcomp}
\DeclareUnicodeCharacter{20AC}{\EUR{}}
\DeclareUnicodeCharacter{2260}{\neq}
\DeclareUnicodeCharacter{2264}{\leq}
\DeclareUnicodeCharacter{2265}{\geq}
\DeclareUnicodeCharacter{22C5}{\cdot}
\DeclareUnicodeCharacter{A0}{~}
\DeclareUnicodeCharacter{B1}{\pm}
\DeclareUnicodeCharacter{D7}{\times}
%%=============================================================================
%% Properties
\title{${1:Title}}
\author{${2:P.~\textsc{Neidhardt}}}
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\let\thedate\@date
\makeatother
%%=============================================================================
%% Aliases
\usepackage{xspace}
\let\latexbak\LaTeX
\renewcommand{\LaTeX}{\textrm{\latexbak}\xspace}
\let\texbak\TeX
\renewcommand{\TeX}{\textrm{\texbak}\xspace}
\def\unix{\textsc{Unix}\xspace}
\def\ie{\textsl{i.e.}\xspace}
\def\eg{\textsl{e.g.}\xspace}
%%=============================================================================
%% Formatting
% \usepackage{parskip}
% \setlength{\parindent}{15pt}
% \renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\renewcommand{\arraystretch}{1.4}
% \renewcommand{\familydefault}{\sfdefault}
%% Header
% \usepackage{fancyhdr}
% \setlength{\headheight}{15.2pt}
% \pagestyle{fancy}
% \lhead{\thetitle}
% \rhead{\theauthor}
%%==============================================================================
%% Tables
% \usepackage{longtable}
% \usepackage{tabu}
%%==============================================================================
%% Graphics
%% Load TikZ after xcolor.
\usepackage[svgnames]{xcolor}
% \usepackage{graphicx}
% \usepackage{tikz}
% \newcommand{\fancybox}[1]{
% \begin{tikzpicture}
% \node[draw,rounded corners]{#1};
% \end{tikzpicture}
% }
%%==============================================================================
%% Misc.
\usepackage{comment}
\usepackage{needspace}
% \usepackage{calc}
% \usepackage{fp}
% \usepackage{lipsum}
%%=============================================================================
%% Listings
\usepackage{listings}
%% Source code.
\lstdefinestyle{custom}{
% numbers=left,
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=L,
xleftmargin=\parindent,
% framexleftmargin=\parindent,
language=C,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color{green!40!black},
commentstyle=\itshape\color{purple!40!black},
identifierstyle=\color{blue},
stringstyle=\color{orange},
numberstyle=\ttfamily,
}
\lstset{escapechar=,style=custom,
literate=
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
{à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ò}{{\`u}}1
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ò}{{\`U}}1
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
{€}{{\EUR}}1 {£}{{\pounds}}1
}
\newcommand{\includecode}[2][custom]{
\lstinputlisting[caption=#2, escapechar=, style=#1]{#2}}
%%=============================================================================
%% Babel
%% Load last before 'hyperref'.
\usepackage[french,ngerman,english]{babel}
\iflanguage{french}{
}{
%% Narrow items
\newlength{\wideitemsep}
\setlength{\wideitemsep}{.5\itemsep}
\addtolength{\wideitemsep}{-7pt}
\let\olditem\item
\renewcommand{\item}{\setlength{\itemsep}{\wideitemsep}\olditem}
}
%%==============================================================================
%% Hyperref
%% Load last.
\usepackage[]{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=DarkRed,
linktoc=page,
urlcolor=blue,
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\maketitle
% \vfill
% \thispagestyle{empty}
% \tableofcontents
$0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -1,176 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com> 2012-04-27
# key: beamer
# group: skeleton
# name: \documentclass{beamer} ...
# --
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[svgnames]{beamer} % xcolor=latex,table
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{geometry}
\usepackage{lmodern}
\usepackage{marvosym}
\usepackage{textcomp}
\DeclareUnicodeCharacter{20AC}{\EUR{}}
\DeclareUnicodeCharacter{2264}{\leqslant}
\DeclareUnicodeCharacter{2265}{\geqslant}
%%=============================================================================
%% Properties
\title{${1:Title}}
\subtitle{${2:Subtitle}}
\author{${3:\textcolor{structure.fg!60!white}{P.~Neidhardt}}}
\institute{\textcolor{sidebarSection}{${4:Institute}}}
%%==============================================================================
%% Aliases
\usepackage{xspace}
\let\latexbak\LaTeX
\renewcommand{\LaTeX}{{\rm \latexbak}}
\let\texbak\TeX
\renewcommand{\TeX}{{\rm \texbak}}
\def\unix{\textsc{Unix}}
%%==============================================================================
%% Beamer config
%% Remove navigation bar.
\beamertemplatenavigationsymbolsempty
%% Colors
\colorlet{sidebarSection}{orange!100!black}
\colorlet{sidebarSub}{yellow!100!black}
%% Themes
\usecolortheme{whale}
%% Background
\setbeamertemplate{background canvas}[vertical shading][top=white,bottom=white]
%% Bars
\setbeamercolor{frametitle}{bg=black, fg=white}
\useoutertheme[height=0pt]{sidebar}
\setbeamertemplate{sidebar canvas left}[horizontal shading][left=black,right=black]
\setbeamercolor{author in sidebar}{fg=red}
\setbeamercolor{section in sidebar shaded}{fg= sidebarSection}
\setbeamercolor{subsection in sidebar shaded}{fg= sidebarSub}
\setbeamercolor{subsection in sidebar}{fg=white}
\setbeamercolor{title}{fg=white,bg=black}
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=true,shadow=true]
%% Blocks
\setbeamertemplate{blocks}[rounded] [shadow=true]
\setbeamercolor{block title}{fg=white,bg=structure.fg!80!black}
\setbeamercolor{block body}{fg=black,bg=structure.bg!95!black}
\setbeamercolor{block title alerted}{fg=white,bg=DarkRed}
\setbeamercolor{block body alerted}{fg=black,bg=structure.bg!95!black}
\setbeamercolor{block title example}{fg=white,bg=DarkGreen}
\setbeamercolor{block body example}{fg=black,bg=structure.bg!95!black}
%% Footline
\setbeamertemplate{footline}[page number]
%% Lists
%% default, triangle, circle, square, ball
%\setbeamertemplate{itemize item}[ball]
%% Auto add frametitle and framesubtitle according to section and subsection.
%% See below to toggle the effect.
\addtobeamertemplate{frametitle}{
\let\insertframetitle\insertsectionhead}{}
\addtobeamertemplate{frametitle}{
\let\insertframesubtitle\insertsubsectionhead}{}
%%==============================================================================
%% Graphics
%% Load TikZ after xcolor.
% \usepackage[svgnames]{xcolor}
% \usepackage{graphicx}
% \usepackage{tikz}
% \newcommand{\fancybox}[1]{
% \begin{tikzpicture}
% \node[draw,rounded corners]{#1};
% \end{tikzpicture}
% }
%%=============================================================================
%% Listings
% \usepackage{listings}
%% Source code.
% \lstdefinestyle{customc}{
% % numbers=left,
% belowcaptionskip=1\baselineskip,
% breaklines=true,
% frame=L,
% xleftmargin=\parindent,
% % framexleftmargin=\parindent,
% language=C,
% showstringspaces=false,
% basicstyle=\footnotesize\ttfamily,
% keywordstyle=\bfseries\color{green!40!black},
% commentstyle=\itshape\color{purple!40!black},
% identifierstyle=\color{blue},
% stringstyle=\color{orange},
% numberstyle=\ttfamily
% }
% \lstset{escapechar=@,style=customc}
%%==============================================================================
%% Babel
\usepackage[frenchb]{babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\titlepage{}
\end{frame}
%% Toggle auto insertion of frametitle and framesubtitle.
\makeatletter
%% \CheckCommand*\beamer@checkframetitle{\@ifnextchar\bgroup\beamer@inlineframetitle{}}
\renewcommand*\beamer@checkframetitle{
\global\let\beamer@frametitle\relax\@ifnextchar\bgroup\beamer@inlineframetitle{}
}
\makeatother
%%==============================================================================
\section{Frame}
\subsection{Classic frame}
\begin{frame}
\begin{alertblock}{Alert block}
Boom!
\end{alertblock}
\end{frame}
\subsection{With source code}
\begin{frame}[shrink,fragile]
\begin{lstlisting}[caption=Hello world!]
int main(int argc, char** argv)
{
printf("Hello world\n");
return 0;
}
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# contributor : Bjorn Reese <breese@users.sourceforge.net>
# key: begin
# group: environments
# name: \begin{environment} ... \end{environment}
# --
\begin{$1}
$0
\end{$1}

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: bib
# group: misc
# name: \bibliography
# --
\bibliographystyle{plain}
\bibliography{$1}$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Claudio Marforio <marforio@gmail.com>
# key: block
# group: environments
# name : \begin{*block} ... \end{*block}
# --
\begin{${1:$$(yas/choose-value '("block" "exampleblock" "alertblock"))}}{${2:Block Title}}
\end{$1}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: case
# group: math
# name: \begin{cases} ... \end{cases}
# --
\begin{cases}
$0 \\\\
\end{cases}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com>
# key: center
# group: environments
# name: \begin{center}
# --
\begin{center}
$0
\end{center}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : cha
# group: sections
# name : \chapter
# option: \label{${2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\chapter{${1:name}}
$0

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : cha*
# group: sections
# name : \chapter*
# --
\chapter*{${1:name}}
$0

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor : Marcio M. Ribeiro <marcio.mr@gmail.com>
# key: cite
# group: references
# name : \cite
# --
\cite{${1:label$(unless yas/modified-p (reftex-citation nil 'dont-insert))}}$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : desc
# group: environments
# name : \begin{description} ... \end{description}
# --
\begin{description}
\item[$0]
\end{description}

View File

@ -1,18 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: doc
# name: \documentclass
# --
\documentclass[$2]{${1:$$(yas/choose-value '("article" "report" "book" "letter"))}}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{marvosym}
\usepackage{textcomp}
\DeclareUnicodeCharacter{20AC}{\EUR{}}
\DeclareUnicodeCharacter{2264}{\leqslant}
\DeclareUnicodeCharacter{2265}{\geqslant}
\begin{document}
$0
\end{document}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key: enum
# group: environments
# name : \begin{enumerate} ... \end{enumerate}
# --
\begin{enumerate}
\item $0
\end{enumerate}

View File

@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: eq
# group: math
# name: \begin{equation} ... \end{equation}
# option: \label{${1:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\begin{equation}
$0
\end{equation}

View File

@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: eqs
# group: math
# name: \begin{align} ... \end{align}
# --
\begin{${1:$$(yas/choose-value '("align" "align*" "multline" "gather" "subequations"))}}
\label{${2:label}}
$0
\end{$1}

View File

@ -1,12 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : fig
# group: environments
# name : \begin{figure} ... \end{figure}
# option: \label{${2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\begin{figure}[htbp]
\centering
$0
\caption{${1:caption}}
\end{figure}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Claudio Marforio <marforio@gmail.com>
# key: frame
# group: environments
# name : \begin{frame} ... \end{frame}
# --
\begin{frame}{${1:Frame Title}}
\end{frame}

View File

@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : graphics
# name : \includegraphics
# --
\includegraphics[width=${1:\linewidth}]{${2:file}}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : item
# group: environments
# name : \begin{itemize} ... \end{itemize}
# --
\begin{itemize}
\item $0
\end{itemize}

View File

@ -1,8 +0,0 @@
-*- mode: snippet -*-
# contributor : Márcio M. Ribeiro <marcio.mr@gmail.com>
# key: lab
# group: references
# name : \label
# option: \label{${1:label$(unless yas/modified-p (reftex-label nil 'dont-insert))}}$0
# --
\label{$1}$0

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: lil
# group: environments
# name: \lstinline
# --
\lstinline @$1@$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: listing
# group: environments
# name: \begin{lstlisting}
# --
\begin{lstlisting}
$0
\end{lstlisting}

View File

@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# contributor: Song Qiang <tsiangsung@gmail.com>
# key: matrix
# group: math
# name: \begin{matrix} ... \end{}
# --
\begin{${1:$$(yas/choose-value '("pmatrix" "bmatrix" "Bmatrix" "vmatrix" "Vmatrix" "smallmatrix"))}}
\label{${2:label}}
$0
\end{$1}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: minipage
# group: environments
# name: \begin{minipage}[position][width] ... \end{minipage}
# --
\begin{minipage}[${1:htbp}]{${2:1.0}${3:\linewidth}}
$0
\end{minipage}

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key: par
# group: sections
# name : \paragraph
# option: \label{${2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\paragraph{${1:name}}
$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor: Mads D. Kristensen <madsdk@gmail.com>
# key: parbox
# group: environments
# name: \parbox{...}
# --
\parbox[${1:htbp}]{${2:1.0}${3:\linewidth}}{
$0
}

View File

@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com> 2012-10-13
# key: pie
# group: tikz
# name: pie chart
# --
\piechart{${1:color}}{${2:scale}}{${3:value1/label1, value2/label2,...}}

View File

@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com> 2012-08-22
# key: plot
# group: tikz
# name: plot
# --
\\${1:plottype}{${2:plotname}}%
{${3:abscissa legend}}
{${4:ordinate legend}}
$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Pierre Neidhardt <ambrevar at gmail dot com>
# key: quote
# group: environments
# name: \begin{quote}
# --
\begin{quote}
$0
\end{quote}

View File

@ -1,7 +0,0 @@
-*- mode: snippet -*-
# contributor : Márcio M. Ribeiro <marcio.mr@gmail.com>
# key: ref
# group: references
# name : \ref
# --
\ref{${1:label$(unless yas/modified-p (reftex-reference nil 'dont-insert))}}$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : sec
# group: sections
# name : \section
# option: \label{${2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\section{${1:name}}
$0

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key : sec*
# group: sections
# name : \section*
# --
\section*{${1:name}}
$0

View File

@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key: ssub
# group: sections
# name : \subsubsection
# option: \label{${2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-insert))}}
# --
\subsubsection{${1:name}}
$0

View File

@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor : Mads D. Kristensen <madsdk@gmail.com>
# key: ssub*
# group: sections
# name : \subsubsection*
# --
\subsubsection*{${1:name}}
$0

Some files were not shown because too many files have changed in this diff Show More