(progn ; early initialization (progn ; these progn for indentation only ;;;(setq debug-on-error t) ; in some cases this is not enough ; when .emacs itself has errors, you may need --debug-init on the command line, when launching Emacs ;;; no idea why this is appearing in trace messages: Warning: no fonts matching `-*-fixed-medium-r-normal-*-16-*-*-*-*-*-iso8859-1' available [2 times] (menu-bar-mode 0) ; early, else menu flashes on screen (setq load-path (append (list "/usr/local/share/emacs/site-lisp" ;; others here . . . ) load-path)))) ; . . . and other load-path appends, below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defface error '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class grayscale) (background light)) (:foreground "DimGray" :bold t :italic t)) (((class grayscale) (background dark)) (:foreground "LightGray" :bold t :italic t)) (((class color) (background light)) (:foreground "rgb:C0/C0/C0")) (((class color) (background dark)) (:foreground "rgb:E0/A0/A0")) (t (:bold t :italic t))) "Face for error messages and other such alarums." :group 'basic-faces) (defun page-next-buffer() "Pages to the next buffer in alphabetic order." (interactive) (delete-other-windows) ; In case visiting multiple initial files, when Emacs shows a split frame, with a buffer list in the second window; this deletes the second window. Not sure how else to correct it, or where better to place this call -- both after-init-hook and --funcall operate too early, prior to load. Besides, it's not bad to see the buffer list, as long as it goes away, without effort. And this does the trick. (let ((list_of_buffer (_list-buffer-names-in-order_init)) (current_buffer_name (buffer-name))) (while list_of_buffer (if (equal current_buffer_name (car list_of_buffer)) (progn ;;; switch to next list entry or first list entry if current is last (switch-to-buffer (or (car(cdr list_of_buffer)) (car(_list-buffer-names-in-order_init)))) (setq list_of_buffer nil)) (setq list_of_buffer (cdr list_of_buffer)))))) (defun page-previous-buffer() "Pages to the previous buffer in alphabetic order." (interactive) (delete-other-windows) ; per page-next-buffer (let ((list_of_buffer (reverse (_list-buffer-names-in-order_init))) (current_buffer_name (buffer-name))) (while list_of_buffer (if (equal current_buffer_name (car list_of_buffer)) (progn ;;; switch to next list entry or first list entry if current is last (switch-to-buffer (or (cadr list_of_buffer) (car (last (_list-buffer-names-in-order_init))))) (setq list_of_buffer nil))) (setq list_of_buffer (cdr list_of_buffer))))) (defface subdued '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class grayscale) (background light)) (:foreground "DimGray" :bold t :italic t)) (((class grayscale) (background dark)) (:foreground "LightGray" :bold t :italic t)) (((class color) (background light)) (:foreground "rgb:FF/00/00")) (((class color) (background dark)) (:foreground "rgb:C0/C0/C0")) (t (:bold t :italic t))) "Face that is just slightly subdued. To de-emphasize symbolic clutter." :group 'basic-faces) (defface textbender-genetic-face '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class grayscale) (background light)) (:foreground "DimGray" :bold t :italic t)) (((class grayscale) (background dark)) (:foreground "LightGray" :bold t :italic t)) (((class color) (background light)) (:foreground "rgb:FF/00/00")) (((class color) (background dark)) (:foreground "rgb:C0/C0/C0")) (t (:bold t :italic t))) "Face for embedded genetic markup in recombinant texts." :group 'basic-faces) (defface textbender-clipboard-face '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class grayscale) (background light)) (:foreground "DimGray" :bold t :italic t)) (((class grayscale) (background dark)) (:foreground "LightGray" :bold t :italic t)) (((class color) (background light)) (:foreground "rgb:FF/00/00")) (((class color) (background dark)) (:foreground "rgb:C0/C0/C0")) (t (:bold t :italic t))) "Face for temporary genes from clipboard." :group 'basic-faces) ;;;; I m p l e m e n t a t i o n ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun _activate-behaviour-modes_init() "Activate various behaviour modes." ;; Custom's stuff. Placed here in case it activates modes. ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;; cannot move these into plain setq's, or it dies (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! ;; Your init file should contain only one such instance. '(pc-select-meta-moves-sexps t) '(pc-select-selection-keys-only t) '(pc-selection-mode t nil (pc-select))) ;; - - - ;(when (string-equal window-system "x") ; (mouse-wheel-mode)) ;;; now on by default, and this would toggle it off see _x_init() ) (defun _do-nothing_init() nil) (defun _ebuild-mode_init() "Initialze Gentoo ebuild mode." (define-derived-mode ebuild-mode shell-script-mode "ebuild" "Gentoo ebuild files." ;; per http://www.gentoo.org/doc/en/gentoo-howto.xml: (setq indent-tabs-mode 1) ) (add-to-list 'auto-mode-alist '("[^/]\\.ebuild$" . ebuild-mode)) (add-to-list 'auto-mode-alist '("^/home/mike/project/.+/ebuild$" . ebuild-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.eclass$" . ebuild-mode)) ) (fset '_html-a-href_init [?\C-w ?< ?a ? ?h ?r ?e ?f ?= ?' ?' ?> ?\C-v ?< ?/ ?a ?> ?\C-r ?< ?a right right right right right right right right right]) (fset '_html-a-href-target_init [?\C-w ?< ?a ? ?h ?r ?e ?f ?= ?' ?' ? ?t ?a ?r ?g ?e ?t ?= ?' ?_ ?t ?o ?p ?' ?> ?\C-v ?< ?/ ?a ?> ?\C-r ?< ?a right right right right right right right right right]) (defun _html-common-mode-hook_init() "HTML related init hook, common to various mode hooks." (fset '_double_quote [?\C-w ?& ?# ?x ?2 ?0 ?1 ?C ?; ?\C-v ?& ?# ?x ?2 ?0 ?1 ?D ?;]) (fset '_single_quote [?\C-w ?& ?# ?x ?2 ?0 ?1 ?8 ?; ?\C-v ?& ?# ?x ?2 ?0 ?1 ?9 ?;]) ) (defun _html-common-mode_init(mode-map) "HTML related init, common to various modes." ;; Many keys cannot be bound here, because bindings are clobbered in sgml-mode.el. ;; Test first with describe-key-briefly. Changing, change also in swatch.txt. (define-key mode-map [?\C-c ?, ?a ?h] '_html-a-href_init) (define-key mode-map [?\C-c ?, ?i] '_html-id_init) (define-key mode-map [?\C-c ?, ?s] '_html-span-aside) (define-key mode-map [?\C-c ?'] '_single_quote) (define-key mode-map [?\C-c ?"] '_double_quote) ; " just to end the quote, which is confusing font-lock (define-key mode-map [?\M-,] '_sgml-entag_init) ; was something to do with Emacs tags (define-key mode-map [?\M-.] '_sgml-entag-end_init) ; " ) (fset '_html-id_init [?\C-w ?< ?s ?p ?a ?n ? ?i ?d ?= ?' ?' ?> ?\C-v ?< ?/ ?s ?p ?a ?n ?> ?\C-r ?< ?s right right right right right right right right right right]) (defun _html-mode_init() "Initialze HTML mode." (add-to-list 'auto-mode-alist '("[^/]\\.htmlf$" . html-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.jspf?$" . html-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.jspxf?$" . html-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.xht$" . html-mode)) ) (fset '_html-span-aside [?\C-w ?< ?s ?p ?a ?n ? ?c ?l ?a ?s ?s ?= ?' ?a ?s ?i ?d ?e ?' ?>?\C-v ?< ?/ ?s ?p ?a ?n ?>]) (defun _indent-relative-plain_init() (indent-relative t)) (defun _init() "Initialize. A grab-bag of general, initial configuration." (setq auto-save-default nil column-number-mode t default-major-mode 'text-mode default-truncate-lines t font-lock-maximum-decoration '((java-mode . 1)) ; multiple ones allowed - (c++-mode . 1)(java-mode . 1) - etc. ;; see _java-mode_init frame-title-format (format "%%b %%f") inhibit-startup-message t kill-whole-line t make-backup-files nil query-replace-highlight t read-quoted-char-radix 16 vc-cvs-stay-local nil visual-line-fringe-indicators t) ; for visual-line-mode (setq-default fill-column 90 ; otherwise 70 indent-tabs-mode nil tab-width 4) ;(menu-bar-mode nil) ;;; done earlier, q.v. (put 'narrow-to-region 'disabled nil) (setq require-final-newline t) ; (setq-default require-final-newline t) ;; but don't know how to mask it or unset it locally in major modes where it is unwanted ; so instead I could explicitly set it (locally) ;(setq bell-volume 0) ; enforce silence ;;;;; does not work, but this does: (setq ring-bell-function `_do-nothing_init) (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60)) (add-hook 'find-file-hooks '(lambda () (when (eq (string-match "~/code/lib-gwt-svg/x[^/]*/repo/\\(?:com\\|org\\)/" buffer-file-truename) 0) (message "enabling tabs") ; standard for these files (setq indent-tabs-mode 1)) (when (eq (string-match "~/code/uhm/mnt/" buffer-file-truename) 0) ; remote files (message "enabling auto-revert-mode for this remote file") (auto-revert-mode 1)) ; to avoid spurious editing guards: "file changed on disk" (when (eq (string-match "~/var/deploy/" buffer-file-truename) 0) (message-box "warning: this is a built file") ; so I don't forget and edit these things (auto-revert-mode 1)) )) ) (defun _java-mode_init() "Initialze Java mode." (add-hook 'java-mode-hook '(lambda () ; un-derived major mode, *-mode-map are defined only in here (define-key java-mode-map [?\C-c ?, ?a ?h] '_html-a-href-target_init) (define-key java-mode-map [?\C-c ?, ?i] '_html-id_init) (define-key java-mode-map [?\C-c ?, ?s] '_html-span-aside) (define-key java-mode-map [?\C-c ?* ?*] '_open-javadoc) (define-key java-mode-map [?\C-c ?* ?l] '_javadoc-linkplain) (define-key java-mode-map [?\C-c ?/] '_comment-old) (define-key java-mode-map [?\C-c ?p] '_println) (define-key java-mode-map [?\M-,] '_sgml-entag_init) ; was something to do with Emacs tags (define-key java-mode-map [?\M-.] '_sgml-entag-end_init) ; " (define-key java-mode-map [f12] '_comment-down) (define-key java-mode-map [f11] '_comment-down-overwrite) (define-key java-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it ;; undo stuff in cc-mode.el (define-key c-mode-base-map "#" 'self-insert-command) (define-key c-mode-base-map "{" 'self-insert-command) (define-key c-mode-base-map "}" 'self-insert-command) (define-key c-mode-base-map "/" 'self-insert-command) (define-key c-mode-base-map "*" 'self-insert-command) (define-key c-mode-base-map ";" 'self-insert-command) (define-key c-mode-base-map "," 'self-insert-command) (define-key c-mode-base-map ":" 'self-insert-command) ; otherwise inserts a space (define-key c-mode-base-map "(" 'self-insert-command) (define-key c-mode-base-map ")" 'self-insert-command) ; (define-key c-mode-base-map [delete] 'delete-char) ; (define-key c-mode-base-map [backspace] 'delete-backward-char) ;; Java font-lock is an uncustomizeable mess since v. 23. We set it at level 1 (see ;; font-lock-maximum-decoration) only for sake of multiline comments. The rest is ;; coded below from scratch, with snippets from the old font-lock.el (see ;; /usr/local/share/emacs/site-lisp/._). Except variable/parameter declarations, ;; which I found are too complicated, even to copy. (font-lock-add-keywords nil '( ;; Comments ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ;; comment edge ; ("^ *\\(///.*\\)$" 1 'header-line t) ; ("^ *\\(//\\)" 1 'header-line t) ; ;; commented-out line ; ("^\\(//.*\\)$" 1 'header-line t) ;; GWT JSNI methods ; ("/\\*-[{]\\(.*\\)\\}-\\*/;" 1 font-lock-constant-face t) ; t override existing fontification ; ; [{] is needed instead of \\{, or it messes up (Emacs 23.1.1) ;; no point, because this won't do multi-line font-lock (which is complicated) ;; javadocs ("^ *\\(?:/\\*\\)?\\* *@?\\(.*\\)$" 1 font-lock-doc-face t) ; t override existing fontification ;; Early ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;; Hopefully doing these early will help stabilize them. Sometimes they fail to ;; take on a newly opened file. But I think that was because I forgot to use the ;; 'laxmatch' parameter in some of the subexp-highlighters for optional groups, ;; e.g. (2 font-lock-type-face) instead of (2 font-lock-type-face nil t). ;; generic formal parameter (sometimes fails on newly opened file) ("[^ ]\\(<\\)\\([^>]+>*\\)\\(>\\)" (1 font-lock-comment-face)(2 font-lock-builtin-face)(3 font-lock-comment-face)) ("static +\\(<\\)\\([^>]+>*\\)\\(>\\) " (1 font-lock-comment-face)(2 font-lock-builtin-face)(3 font-lock-comment-face)) ;; subdued keywords ;; get these out of the way, or extends|implements can be taken as variable names ("\\<\\(extends\\|implements\\|native\\|throws\\|void\\)\\>" . 'subdued) ;; method, variable and constant declarations ("[^@]\\<[A-Z][A-Za-z0-9_.]*\\(?:<[^>]+>+\\)?\\(?:\\[\\]\\)* +\\([a-z_]\\w*\\)\\>(" 1 font-lock-function-name-face) ;; -A- --------T---------- ---G---- --[]-- -----N---- ("[^@]\\<[A-Z][A-Za-z0-9_.]*\\(?:<[^>]+>+\\)?\\(?:\\[\\]\\)* +\\([a-z_]\\w*\\|[A-Z_]+\\)\\>[^(]" 1 font-lock-variable-name-face) ;; -A- --------T---------- ---G---- --[]-- -----N-------------- ;; A annotations ignored, not taken as type name ;; T type ;; G optional generic formal parameter ;; [] optional array brackets ;; N method, variable or constant name ("\\<\\(?:boolean\\|byte\\|char\\|double\\|float\\|int\\|long\\|short\\|void\\)\\(?:\\[\\]\\)* +\\([a-z_]\\w*\\)\\>(" 1 font-lock-function-name-face) ;; -----------------------------------T------------------------------ --[]-- -----N---- ("\\<\\(?:boolean\\|byte\\|char\\|double\\|float\\|int\\|long\\|short\\|void\\)\\(?:\\[\\]\\)* +\\([a-z_]\\w*\\|[A-Z_]+\\)\\>[^(]" 1 font-lock-variable-name-face) ;; -----------------------------------T------------------------------ --[]-- -----N------------ ;; T type, including 'var' for sake of Javascript ;; [] optional array brackets ;; N method or variable name ;; for Javascript: ("\\<\\function +\\([a-z_]\\w*\\)\\>(" 1 font-lock-function-name-face) ("\\<\\var +\\([a-z_]\\w*\\)\\>[^(]" 1 font-lock-variable-name-face) ;; Middle ;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;; annotation (copied from old version of emacs) ("\\(@\\)\\(\\w+\\(?:\\.\\w+\\)*\\)\\(?: *\\((\\) *\\([^)]*\\)\\()\\)\\)?" (1 font-lock-comment-face)(2 'subdued)(3 'subdued t t)(4 font-lock-comment-face t t) (5 'subdued t t)) ; ("\\<\\(class\\)\\>[ \t]*\\(\\w+\\)?" ;; but avoid .class and tokens after it, and add enum|interface: ("\\(?:[^.]\\|^\\)\\<\\(class\\|enum\\|interface\\)\\>[ \t]*\\(\\w+\\)?" (1 font-lock-keyword-face) (2 font-lock-type-face nil t)) ;; keyword ("\\<\\(catch\\|do\\|else\\|finally\\|for\\|if\\|return\\|switch\\|throw\\|try\\|while\\)\\>" . font-lock-keyword-face) ("\\<\\(abstract\\|final\\|private\\|protected\\|public\\|static\\|transient\\|volatile\\)\\>" . 'subdued) ("\\b\\(synchronized\\) *[^(]" 1 'subdued) ; see also synchronized (as statement) below ("^package " . 'subdued) ("^ *\\(import .*\\);" 1 'subdued t) ("\\bassert\\b.+?;" 0 font-lock-comment-face t) ("[lL]ogger.+\\(?:log\\|severe\\|warning\\|info\\|config\\|fine\\|finer\\|finest\\)(.+?;" 0 font-lock-comment-face t) ("\\b\\(?:\\w+\\.\\)?report[(].+?[)];" 0 font-lock-comment-face t) ; for JavaScript ("\\<\\(break\\|case\\|continue\\|goto\\)\\>[ \t]*\\(-?\\w+\\)?" ; copied from old version of emacs (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) ;; this must follow the above ; ("^[ \t]*\\(\\w+\\)[ \t]*:[ \t]*$" ("^[ \t]*\\(\\w+\\)[ \t]*:[ \t]*" (beginning-of-line) (end-of-line) (1 font-lock-constant-face)) ;; punctuation ("[;,:]" . font-lock-comment-face) ("['\"]" 0 font-lock-comment-face t) ("[{}]" . 'subdued) ;; synchronized (as statement, not as qualifier) ("\\b\\(synchronized\\) *(" 1 font-lock-keyword-face) ;; System.exit ("\\b\\(System\\)\\.\\(exit\\) *(" (1 font-lock-keyword-face)(2 font-lock-keyword-face)) )) ; (font-lock-remove-keywords nil ; '( ; ;; GWT native JavaScript ; "/\\*-\\{.*?\\}-\\*/" ; )) ;; unfortunately this has no effect (fset '_comment-down [?/ ?/ left left down]) (fset '_comment-down-overwrite [insert ?/ ?/ insert left left down]) (fset '_comment-old [?/ ?* ?* ?/ left left]) ;;;(fset '_comment-up [?/ ?/ left left up]) ;;;(fset '_comment-up-overwrite [insert ?/ ?/ insert left left up]) (fset '_javadoc-linkplain [?\C-w ?{ ?@ ?l ?i ?n ?k ?p ?l ?a ?i ?n ? ?\C-v ?} ?\C-r ?{ ?@ ?l ?i ?n ?k C-right ? ?#]) (fset '_open-javadoc [f8 ?/ ?* ?* return ? ? ?* ?/ up ? ?. left]) (fset '_println [?S ?y ?s ?t ?e ?m ?. ?o ?u ?t ?. ?p ?r ?i ?n ?t ?l ?n ?( ? ?" ? ?- ?- ?- ? ?= ?" ? ?+ ? ? ?) ?\; left left left left left left left left]) (setq abbrev-mode nil ; otherwise infinite regress involving c-electric-continued-statement() occurs after you type "else" or other words in abbrev table indent-line-function '_indent-relative-plain_init ) (message nil) )) (add-to-list 'auto-mode-alist '("[^/]\\.css$" . java-mode)) ; for the sake of the comments (add-to-list 'auto-mode-alist '("[^/]\\.js$" . java-mode)) ; JavaScript executable (add-to-list 'auto-mode-alist '("[^/]\\.jsm$" . java-mode)) ; JavaScript module ) (defun _keys_init() "Set initial key bindings and related configuration." (global-unset-key [f10]) ; was tmm-menubar (global-unset-key [?\C-a]) ; was beginning-of-line, but I use "Home" key instead ;(global-unset-key [?\C-d]) ; was delete-char, but I use "Delete" key instead ;;;;; but then the Delete key ceases to function (apparently it is remapped to [d at a low level? (global-unset-key [?\C-o]) ; was open-line, but I use my _open-line-before_init/after (global-unset-key [?\C-x ?u]) ; was advertised-undo, but I use |[- for this (global-unset-key [?\C-x ?\C-z]) ; was iconify-or-deiconify-frame, but I don't ever do that (makes window disappear, as though killed) (global-unset-key [?\C-z]) ; was iconify-or-deiconify-frame (global-set-key [C-prior] 'page-previous-buffer) ; was scroll-right (global-set-key [C-next] 'page-next-buffer) ; was scroll-left ;(when (string-equal window-system "x") (global-set-key [C-mouse-4] 'page-previous-buffer) (global-set-key [C-mouse-5] 'page-next-buffer) ; ) ;; file ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` (global-set-key [?\C-x ?s] '_save-all-buffers_init) ; was save-some-buffers (which prompts, whereas this is silent) ;; window & frame ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` (global-set-key [?\C-l] 'recenter) ; was recenter-top-bottom (global-set-key [?\C-x <] 'scroll-right) ; was scroll-left (global-set-key [?\C-x >] 'scroll-left) ; was scroll-right (global-set-key [M-down] (function (lambda nil (interactive) ; was backward-line-nomark (scroll-up 1)))) (global-set-key [M-up] (function (lambda nil (interactive) ; was forward-line-nomark (scroll-down 1)))) ;; mark & point ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` (setq search-highlight t) ;(setq track-eol t) ; too surprising, when you don't want it ;(transient-mark-mode t) ; already enabled (by pc-selection-mode?) (global-set-key [C-home] 'beginning-of-buffer) ; was beginning-of-buffer-nomark (global-set-key [C-end] 'end-of-buffer) ; was end-of-buffer-nomark; can also use M-> ;; edit ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` (global-unset-key [?\C-j]) ; was newline-and-indent (global-set-key [?\r] 'newline-and-indent) ; was newline (global-set-key [M-return] 'newline) (global-set-key [f5] (function (lambda nil (interactive) (indent-rigidly (region-beginning)(region-end) -1)))) (global-set-key [f6] 'indent-rigidly) (global-set-key [f7] '_newline-before_init) (global-set-key [f9] '_newline-after_init) (global-set-key [f8] '_open-line-before_init) (global-set-key [f10] '_open-line-after_init) ;; kill & yank ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ;(global-set-key [?\C-c] 'copy-region-as-kill-nomark) ;;;;; bad idea, because it's a standard prefix (modes will clobber it) (global-set-key [?\C-v] 'yank) ; was scroll-up (global-set-key [?\M-v] 'yank-pop) ; was scroll-down (global-set-key [?\M-k] '_kill-ring-save-line_init) ; was kill-sentence ;; rectangle ;; ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` (global-unset-key [?\C-x ?r ?y]) ; was yank-rectangle (global-set-key [?\C-x ?r ?v] 'yank-rectangle) ) (fset '_kill-ring-save-line_init "\C-k\C-_") (defun _list-buffer-names-in-order_init() "Return a sorted list of buffer names. Exclude those whose names start or end with '*'." (require 'cl) (let (buffer_names) (loop for a_buffer in (buffer-list) do (let ((a_name (buffer-name a_buffer))) (if (not (or (equal"*" (substring a_name 0 1)) ; starts with * (equal "*" (substring a_name -1)) ; ends with * ;;;(string= a_name "TAGS") ; what was purpose of this? ;;;(string= a_name " SPEEDBAR") ; "? ;;;(equal "*" (substring a_name 1 2)) ; fails for file names of length 1. What was purpose of this? )) (setq buffer_names (cons a_name buffer_names))))) (sort buffer_names '_string-lessp-i))) (defun _mediawiki-mode_init() "Initialze MediaWiki mode." (define-derived-mode mediawiki-mode html-mode "MediaWiki" "Major mode for editing MediaWiki markup.") (defun end-of-visual-line-mark() ; cf. pc-select.el end-of-line-mark; 'define-key' will not take a lambda expression, it always wants an interactive function (aka a command) "Ensure mark is active; move point to the end of the visual line." ; (interactive "^") ; ^ shift-translation command, but no dice, I guess we have to do it the pc-select way: (interactive) (pc-select-ensure-mark) (end-of-visual-line)) (defun beginning-of-visual-line-mark(); ; cf. pc-select.el beginning-of-line-mark "Ensure mark is active; move point to the beginning of the visual line." (interactive) (pc-select-ensure-mark) (beginning-of-visual-line)) (add-hook 'mediawiki-mode-hook '(lambda () (font-lock-add-keywords nil '( ("\\(=+\\)\\([^'].*\\)\\(\\1\\)" ; heading (1 font-lock-comment-face t)(2 font-lock-keyword-face t)(3 font-lock-comment-face t)) ;;; the [^'] rule helps avoid false matches in html "class='etc' href='etc'" ("\\(\\[\\[\\)\\(?:\\(.+?\\)\\(|\\)\\)?\\([^]|].*?\\)\\(]]\\)" ; internal link [[loc]] or [[loc|body]] (1 font-lock-comment-face t)(2 'subdued t t)(3 font-lock-comment-face t t) (4 font-lock-function-name-face)(5 font-lock-comment-face t)) ("\\(\\[\\)\\(http://.+? \\)?\\(.+?\\)\\(]\\)" ; external link [loc] or [loc body] (1 font-lock-comment-face t)(2 'subdued t t)(3 font-lock-function-name-face) (4 font-lock-comment-face t)) ("http://[^[:space:]<>']+" . font-lock-function-name-face) ; external link (bare) ("{{\\(.+\\)}}" (1 font-lock-builtin-face t)) ; magic words and code ("[{}']" 0 font-lock-comment-face t) ; t override existing fontification )) (setq fill-column 70) ; most fixed formatting in wiki is intended for pasting to 70-col email (visual-line-mode) )) (add-to-list 'auto-mode-alist '("itsalltext.*\\.txt$" . mediawiki-mode)) (define-key mediawiki-mode-map [end] 'end-of-visual-line) ; was end-of-line-nomark (define-key mediawiki-mode-map [S-end] 'end-of-visual-line-mark) ; was end-of-line-mark (define-key mediawiki-mode-map [home] 'beginning-of-visual-line) ; was beginning-of-line-nomark (define-key mediawiki-mode-map [S-home] 'beginning-of-visual-line-mark) ; was beginning-of-line-mark (define-key mediawiki-mode-map [?\M-,] '_sgml-entag_init) ; was something to do with Emacs tags (define-key mediawiki-mode-map [?\M-.] '_sgml-entag-end_init) ; " (define-key mediawiki-mode-map [?\M-q] `undefined) ; was fill-paragraph, not needed in visual-line-mode (define-key mediawiki-mode-map [?\C-\M-q] `fill-paragraph) ; in case you still need it (modify-coding-system-alist 'file "itsalltext.*\\.txt\\'" 'utf-8) ) (defun _modes_init() "Configure major and minor modes." (_ebuild-mode_init) (_html-mode_init) (_java-mode_init) (_mediawiki-mode_init) (_mutt-mode_init) (_perl-mode_init) (_sh-mode_init) (_sgml-mode_init) (_task-sheet-mode_init) (_text-mode_init) ;(autoload 'python-mode "python-mode" "Python editing mode." t) ;(add-to-list 'interpreter-mode-alist '("python" . python-mode)) (add-to-list 'interpreter-mode-alist '("runscript" . shell-script-mode)) ; Gentoo init scripts (add-to-list 'auto-mode-alist '("[./]php5?$" . shell-script-mode)) ; PHP sources (add-to-list 'auto-mode-alist '("[./]properties$" . shell-script-mode)) ; Java properties ; ; (autoload 'wikipedia-mode "wikipedia-mode.el" "Major mode for editing MediaWiki markup." t) ; (add-to-list 'auto-mode-alist '("itsalltext.*\\.txt$" . wikipedia-mode)) ) (defun _mutt-mode_init() "Initialze Mutt mode." (define-derived-mode mutt-mail-mode text-mode "Mutt-Mail" "For composing mail in a buffer invoked by Mutt." (setq show-trailing-whitespace nil ;;; indent-line-function 'indent-relative) fill-column 70) ; though usually you must set this in a mode hook (defvar mutt-mail-font-lock-keywords (list '("^\\(?:From: \\|Cc: \\|Bcc: \\|Message-ID: \\|Reply-To: \\|In-Reply-To: \\).*$" . font-lock-comment-face) '("^\\(?:To: \\).*$" . font-lock-string-face) '("^\\(?:Subject: \\).*$" . font-lock-type-face) '("^\\(?: *> *>\\)+ *\\(?:[^ >\xA].*\\)?$" ; quote me (even) . font-lock-comment-face) '("^ *>.*$" ; quote other (odd) . font-lock-string-face) '("^-- $" ; signature delimiter . font-lock-comment-face) '("^\\(?:Mike\\|Michael Allan\\)$" ; signature . font-lock-comment-face) ) "For mutt-mail-mode.") (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(mutt-mail-font-lock-keywords t)) ) (add-to-list 'auto-mode-alist '("mutt-.+-[0-9]+-[0-9]+\\'" . mutt-mail-mode)) (add-hook 'mutt-mail-mode-hook '(lambda () ;; (make-local-variable 'require-final-newline) ;; (setq require-final-newline nil) ;;;; no effect ; rather than unsetting it like this, explicitly, I would have to set it explicitly everywhere else [just don't like how Mutt's viewer shows the final newline] but it's not worth it [and mail handlers append newlines etc. anyway, it seems] (re-search-forward "^$") ; move down to 1st blank line, past the headers (forward-line) ; and one more, to beginning of message body )) ) (fset '_newline-after_init [end M-return]) (fset '_newline-before_init [home M-return up]) (fset '_open-line-after_init [end return]) (fset '_open-line-before_init [end return ?\C-x ?\C-t up up end]) (defun _perl-mode_init() "Initialze Perl mode." ;; Note that perl-mode (but not cperl-mode) became partly broken with version 23 or so, ;; sometime in 2010. It fails to fontify variables and keywords, for example. It ;; matters not whether this init function is used, or the old patched perl-mode.el is on ;; the local path. Setting font-lock-maximum-decoration to 3 does not help either. Nor ;; does blindly following the instructions in perl-mode.el, such as setting "(autoload ;; 'perl-mode "perl-mode")". (add-hook 'perl-mode-hook '_perl-mode_hook) (add-hook 'cperl-mode-hook '_cperl-mode_hook) ;; Add these if you want cperl mode instead of perl mode: (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode)) ) (defun _cperl-mode_hook() ; un-derived major mode, *-mode-map are defined only in here (fset '_comment-down [?# left down]) (fset '_comment-down-overwrite [insert ?# insert left down]) (fset '_println [?p ?r ?i ?n ?t ?( ? ?" ? ?- ?- ?- ? ?\\ ?= ?" ? ?. ? ? ?. ? ?" ?\\ ?n ?" ? ?) ?\; left left left left left left left left left left left left left left left]) (define-key cperl-mode-map [?\C-c ?p] '_println) (define-key cperl-mode-map [f12] '_comment-down) (define-key cperl-mode-map [f11] '_comment-down-overwrite) ;; undo stuff in cperl-mode.el (define-key cperl-mode-map [?{] 'self-insert-command) ; was cperl-electric-lbrace (define-key cperl-mode-map [?}] 'self-insert-command) ; was cperl-electric-brace (define-key cperl-mode-map [tab] 'tab-to-tab-stop) ; was cperl-indent-command, to which C-i still maps (font-lock-add-keywords nil '( ;; subdue punctuation ("[,;:]" . font-lock-comment-face) ("['\"]" 0 font-lock-comment-face t) ; t override existing fontification ;;;("[{}$@%*]" . 'subdued) ;;;;; but $@ (and presumeably %*) somehow defeat fontification of variable names ("[{}]" . 'subdued) )) (setq indent-line-function '_indent-relative-plain_init) (message nil) ) (defun _perl-mode_hook() ; un-derived major mode, *-mode-map are defined only in here (fset '_comment-down [?# left down]) (fset '_comment-down-overwrite [insert ?# insert left down]) ;;;(fset '_comment-up [insert ?# insert left up]) ;;;(fset '_comment-up-overwrite [insert ?# left up]) (fset '_println [?p ?r ?i ?n ?t ?( ? ?" ? ?- ?- ?- ? ?\\ ?= ?" ? ?. ? ? ?. ? ?" ?\\ ?n ?" ? ?) ?\; left left left left left left left left left left left left left left left]) (define-key perl-mode-map [?\C-c ?p] '_println) (define-key perl-mode-map [f12] '_comment-down) (define-key perl-mode-map [f11] '_comment-down-overwrite) ;; undo stuff in perl-mode.el (define-key perl-mode-map [?{] 'self-insert-command) ; auto-indent too often wrong (define-key perl-mode-map [?}] 'self-insert-command) (define-key perl-mode-map [?;] 'self-insert-command) (define-key perl-mode-map [?:] 'self-insert-command) (define-key perl-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it (font-lock-add-keywords nil '( ;; subdue punctuation ("[,;:]" . font-lock-comment-face) ("['\"]" 0 font-lock-comment-face t) ; t override existing fontification ("[{}$@%*]" . 'subdued) ; unless already fontified )) (setq indent-line-function '_indent-relative-plain_init) (message nil) ) (defun _save-all-buffers_init() (interactive) (save-some-buffers t)) (defun _sh-mode_init() "Initialze shell mode." (add-hook 'sh-mode-hook '(lambda () ; un-derived major mode, *-mode-map are defined only in here (define-key sh-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it ; (make-local-variable 'require-final-newline) ; (setq require-final-newline t) )) ) (fset '_sgml-entag_init [?\C- M-left ?\C-w ?< ?\C-v ?>]) (fset '_sgml-entag-end_init "\C-r<\C-m") (defun _sgml-mode_init() "Initialze SGML mode." (add-to-list 'auto-mode-alist '("[./]tld$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.ent$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.mod$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.rdf$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.xml$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.xsd$" . sgml-mode)) (add-to-list 'auto-mode-alist '("[^/]\\.xslt$" . sgml-mode)) (add-hook 'sgml-mode-hook '(lambda () ; un-derived major mode, *-mode-map are defined only in here (define-key sgml-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it ;; undo stuff in sgml-mode.el (define-key sgml-mode-map "/" 'self-insert-command) ; refuses to obey insert/overwrite mode ; (make-local-variable 'require-final-newline) ; (setq require-final-newline t) (_html-common-mode_init sgml-mode-map) (_html-common-mode-hook_init) ; (font-lock-add-keywords ; 'sgml-mode ; '( ; ) ; ) ;;; Fails to affect derived modes like HTML, so instead patch sgml-mode.el (message nil) )) ) (defun _string-lessp-i (string1 string2) "Like 'string-lessp' but ignores case." (setq string1(downcase string1)) (setq string2(downcase string2)) (string-lessp string1 string2) ) (defun _t-b-desktop_init() "Initialize interface to textbender.recombinant.assembly.desktop." (setq load-path (append (list "/home/mike/var/deploy/recombinant-desktop") load-path)) ;(setq load-path (append (list "/tmp/x/recombinant-desktop-0.0.7") load-path)) ;(setq load-path (append (list "/tmp/y/recombinant-desktop-0.0.7") load-path)) (load "textbender/recombinant/assembly/desktop/editor/emacs.gnu.org/interface") (setq java-launcher "/opt/jdk/jre/bin/java") ; "java" is the default (setq population-server "http://localhost:8080") ; "http://ivory.zelea.com:8080" is the default, which is best for most users (setq target-gene-java-option-list ; not required, the default is an empty list (list "-Dt-r-genotypeFont=Courier New-16" ; format per java.awt.Font.decode(), e.g.: 'Georgia-18' or 'Serif BOLD 16' ;; for debugging, in-development testing: "-Djava.util.logging.config.file=/home/mike/mnt/textbender/recombinant/assembly/desktop/editor/java-logging.properties" ; which is also at: http://zelea.com/.config/textbender/recombinant/assembly/desktop/editor/java-logging.properties "-enableassertions:textbender..." "-Xfuture" )) (define-key sgml-mode-map [?\C-c ?g] 'mark-gene) (define-key sgml-mode-map [?\C-c ?t] 'shift-target-gene) ; see also 'target-gene, which creates additional targets (define-key sgml-mode-map [?\C-c ?u] 'untarget-gene) ;(define-derived-mode t-r-html-mode ; html-mode ; "t-r-html" "For ." ; ; (defvar t-r-html-font-lock-keywords ; (list ; '("a" ; . font-lock-comment-face) ; '("1" ; 1 font-lock-comment-face) ; ) ; "For t-r-html-mode.") ; ;; (make-local-variable 'font-lock-defaults) ;; (setq font-lock-defaults '(t-r-html-font-lock-keywords t)) ;;;;;; blows away HTML/SGML font locks, so: ;; (font-lock-add-keywords 'html-mode t-r-html-font-lock-keywords) ;;;;;; no effect ; ) ;;;;; resort to modifying sgml.el directly [but see _mediawiki-mode_init()] ) (defun _task-sheet-mode_init() "Initialze Task-Sheet mode." (define-derived-mode task-sheet-mode fundamental-mode "Task-Sheet" "for .task project plans" (setq indent-line-function '_indent-relative-plain_init) (defconst task-sheet-font-lock-keywords-a (list '("^/.*$" ; / ~ ~~~ complete . font-lock-comment-face) '("^ *\\(/\\) \\(.*\\)$" ; / ~ ~~~ ignore (1 'subdued) (2 font-lock-comment-face)) '("^ *// .*$" ; // ~~~ reason for ignoring . 'subdued) '("^ *\\((\\) \\(.*\\)$" ; ( ~ ~~~ block (1 'font-lock-string-face) (2 font-lock-comment-face)) '("^ *(( .*$" ; (( ~~~ reason for block . 'font-lock-string-face) ) "high priority rules") (defconst task-sheet-font-lock-keywords-filter (list '("^ *\\([.]\\) \\(.*\\)$" ; . ~ ~~~ filter (1 'font-lock-string-face) (2 font-lock-comment-face)) ) "filter rules") (defconst task-sheet-font-lock-keywords-b (list '("^ *_+[ \\t]*$" ; ________ section top line . font-lock-comment-face) '("\\(?:[=!?] \\)?\\(.*\\)`[ \\t]*$" ; ~~~ ` section title . 1) '("^\\(?: [ .] \\)*=\\(.*\\)$" ; = ~~~ task 1 font-lock-function-name-face) '("^\\(?: [ .] \\)*\\+\\(.*\\)$" ; + ~~~ special task 1 font-lock-type-face) '("^\\(?: [ .] \\)*\\?\\(.*\\)$" ; ? ~~~ priority task 1 font-lock-warning-face) '("^\\(?: [ .] \\)*!\\(.*\\)$" ; ! ~~~ priority task 1 'error) ) ; ~ ~~~ note (i.e. preceded by other char) "all other rules") ;; Font lock decoration levels. ;; These essentially turn filter decorations off or on (default). ;; Use font-lock-decoration-toggle to switch between them. (defconst task-sheet-font-lock-keywords-0 (append task-sheet-font-lock-keywords-a task-sheet-font-lock-keywords-b nil) ; last append item, not copied like those above; so use a dummy [i could just use the list function instead] "disables filter decorations") (defconst task-sheet-font-lock-keywords-1 (append task-sheet-font-lock-keywords-a task-sheet-font-lock-keywords-filter task-sheet-font-lock-keywords-b) "normal decorations") (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '( (task-sheet-font-lock-keywords-0 task-sheet-font-lock-keywords-1) t)) ) (define-key task-sheet-mode-map [?\t] 'tab-to-tab-stop) (define-key task-sheet-mode-map [f12] 'comment-down) (define-key task-sheet-mode-map [f11] 'comment-down-overwrite) (_html-common-mode_init task-sheet-mode-map) (add-hook 'task-sheet-mode-hook '(lambda () (_html-common-mode-hook_init) ; (make-local-variable 'require-final-newline) ; (setq require-final-newline t) (fset 'comment-down [?/ left down]) (fset 'comment-down-overwrite [insert ?/ insert left down]) (fset 'comment-up [?/ left up]) (fset 'comment-up-overwrite [insert ?/ insert left up]) )) ) (defun _text-mode_init() "Initialze text mode." (define-key text-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it ;(add-hook ; 'text-mode-hook ; '(lambda () ; (define-key text-mode-map [tab] 'tab-to-tab-stop) ; C-i still maps to indent, if you need it ; )) (add-to-list 'auto-mode-alist '("/ChangeLog$" . text-mode)) ; was Change Log, which is not Gentoo format ) (defun _x_init() "Initialize for X Window System." (global-set-key [S-down-mouse-1] 'mouse-save-then-kill) ; was mouse-set-font (global-set-key [mouse-3] 'mouse-set-font) ; the popup button, was mouse-save-then-kill ; (setq mouse-wheel-scroll-amount '(5 ((alt) . 1) ((meta) . 1) )) ;;; Neither alt nor meta works. On use, complains e.g. "M-mouse-4 is undefined". (setq mouse-wheel-scroll-amount '(5 ((shift) . 1) )) (setq-default show-trailing-whitespace t) (setq x-select-enable-clipboard t) ; else kills are invisible to other apps (add-to-list 'default-frame-alist '(unsplittable . t)) (global-font-lock-mode 1) ; (setq-default line-spacing 0) ; trying to prevent the huge line spaces with scalable fonts ; Cursor ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (blink-cursor-mode 0) ;(mouse-avoidance-mode 'cat-and-mouse) ;;;;; but raises window whenever it scurries (show-paren-mode 1) ; colouring them when under point (defun adjust-cursor-type (&optional frame) "Set cursor colour according to overwrite-mode." (modify-frame-parameters (or frame (selected-frame)) (list (cons 'cursor-type (if overwrite-mode 'box 'bar))))) ; (defadvice overwrite-mode (after adjusted-cursor activate) (adjust-cursor-type)) ; (defadvice binary-overwrite-mode (after adjusted-cursor activate) (adjust-cursor-type)) ; (add-hook 'after-make-frame-functions 'adjust-cursor-type) ; (defadvice other-window (after adjusted-cursor activate) (adjust-cursor-type)) ; (defadvice switch-to-buffer (after adjusted-cursor activate) (adjust-cursor-type)) ;; Incomplete. Overwrite mode is per buffer, but cursor type is per frame. ;; Need more hooks to tie them together. Easier to use brute force: (add-hook 'post-command-hook 'adjust-cursor-type) ; OPT slows all commands ;; But eLisp manual says the "buffer-local variable cursor-type overrides ;; the value of the cursor-type frame parameter", so maybe try that? (setq-default cursor-in-non-selected-windows 'hollow) ; else bar becomes (hardly distinguishable) thin bar ; Prevent border appearing when frame loses focus ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; (set-face-background 'border "red") ;; works on in-focus border ; (set-face-foreground 'border "yellow") ;; does nothing ; (set-border-color red) ;; works on in-focus border ; Emacs.borderWidth: (in .Xresources; does nothing) ; ; ; (setq default-frame-alist ; ; '((top . 200) (left . 400) ; ; (border-width . 10) ; ; (width . 80) (height . 40) ; ; (cursor-color . "white") ; ; (cursor-type . box) ; ; (foreground-color . "wheat") ; ; (background-color . "black") ; ; )) ; ;; other parameters in this test code work, you can see 'em in new frames, ; ;; but not border-width (I suspect that is supposed to be WM borders, anyway; ; ;; and not the one I'm looking for) ; ;; Nothing works except this, in .Xresources: ; ; Emacs.foreground: black ; ;; Then setting the proper colour here, in .emacs : ; (set-face-foreground 'default "rgb:E9/E9/E9") ; (set-face-foreground 'default "rgb:40/40/40") ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (progn (progn ; these progn for indentation only (_activate-behaviour-modes_init) ; early, so they don't clobber other, later config (_init) (when (string-equal window-system "x") (_x_init)) (_keys_init) (_modes_init) ;;;(_t-b-desktop_init) ))