chiark / gitweb /
dot/putty-defaults: PuTTY wants to sort the `TerminalModes' line.
[profile] / dot / emacs
index f71b9a245775103f21ac2e05aadf1f6badf4d82d..b726fabebd1832ef732b55212a39f80304522b08 100644 (file)
--- a/dot/emacs
+++ b/dot/emacs
     (if (file-exists-p boot)
        (load boot))))
 
-(require 'dot-emacs)
 (require 'cl)
+(require 'dot-emacs)
+
+(unless (mdw-emacs-version-p 25)
+  (trap (require 'bracketed-paste) (bracketed-paste-enable)))
 
 ;;;--------------------------------------------------------------------------
 ;;; Some random initialisation.
 (require 'paren)
 (trap (show-paren-mode t))
 (or window-system (mdw-emacs-version-p 22) (menu-bar-mode -1))
+(setq x-select-enable-clipboard nil
+      x-select-enable-primary t
+      mouse-drag-copy-region t)
 
 ;; Multiple cursors.
 
 ;; Emacs server behaviour.
 
 (and (or window-system (mdw-emacs-version-p 23))
+     (not mdw-fast-startup)
      (progn (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")
                  edit-server-new-frame nil
                  gnuserv-frame t)
                      (and edit
                           (set-process-query-on-exit-flag edit nil)))))))
 
+;; Saving state.
+
+(or mdw-fast-startup (savehist-mode 1))
+(setq history-length 200)
+
 ;; Control backup behaviour.
 
 (setq backup-by-copying nil)
       send-mail-function 'sendmail-send-it
       mail-interactive t
       sendmail-error-reporting-interactive '("-odb" "-oee"))
+(autoload 'sendmail-send-it "sendmail")
+(autoload 'smtpmail-send-it "smtpmail")
 
 (setq mail-user-agent 'message-user-agent
       read-mail-command 'gnus)
     (trap (bbdb-initialize 'gnus 'sendmail 'message)))
 (setq bbdb-file "~/etc/brain/bbdb"
       bbdb-north-american-phone-numbers-p nil
+      bbdb-dwim-net-address-allow-redundancy t
       bbdb-extract-address-components-func 'bbdb-extract-address-components
       bbdb/news-auto-create-p
       (lambda ()
        (let ((group gnus-newsgroup-name))
-         (and (string-match "^nnimap\\+" group)
-              (not (string-match ":\\(crap\\|spam\\|lists\\)\\." group)))))
+         (and (string-match "^nn\\(imap\\|folder\\)\\+" group)
+              (not (string-match ":\\(crap\\|spam\\|lists\\|corpus\\)\\."
+                                 group)))))
       bbdb-user-mail-names
       (concat "^"
              "\\(" "\\(mdw\\|markw\\|root\\|postmaster\\)"
                    "\\([-+][^@]*\\|\\)"
                    "@\\(\\(dist\\|esc\\)orted\\.org\\.uk\\|odin\\.gg\\)"
+             "\\|" "\\(" "\\(mdw\\|mwooding\\)"
+                         "\\(\\+[^@]*\\)?"
+                   "\\|" "0" "\\(mdw\\|mwooding\\)" "k\\.[^@]*"
+                   "\\)" "@"
+                   "\\(chiark\\|slimy\\|coriolis\\)\\.greenend\\.org\\.uk"
              "\\|" "distorted\\.mdw@g\\(\\|oogle\\)mail.com"
              "\\|" "mwooding@\\(good\\|blackberry\\)\\.com"
              "\\|" "mark\\.wooding@trustonic\\.com"
       (lambda (addr)
        (cond ((null addr)
               nil)
-             ((or (string-match (concat "^reply-[0-9a-f]+-[0-9a-f]+_"
+             ((or (string-match "^mailer-daemon@" addr)
+                  (string-match "\.invalid$" addr)
+                  (string-match (concat "^reply-[0-9a-f]+-[0-9a-f]+_"
                                         "HTML-[0-9]+-[0-9]+-[0-9]+"
                                         "@\\(nationwide-communications\\."
                                         "co\\.uk\\)$")
                                 addr)
                   (member (md5 addr)
                           '("8815c5583970856799c85a3ee0eb6a9f" ;work wiki spam
+                            "0b94ab4d25dacaa5ac07243a09c9e22e" ;work bug spam
+                            "35fb1633379a1e4d4be3b139cae20111" ;work crucible spam
                             ))
                   (and (string-match "^news\\([0-9]+\\)@\\(.*\\)$" addr)
                        (string= (md5 (match-string 2 addr))
     (apply #'set-input-mode
           (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im)))))
 
+;; Some unpleasant terminal hackery.  Screen prefixes the current terminal
+;; name with `screen.', and Emacs is too dim to split the name at the `.'.
+;; Help it out.
+
+(defun terminal-init-screen.xterm ()
+  (tty-run-terminal-initialization (selected-frame) "screen"))
+(defun terminal-init-screen.putty ()
+  (tty-run-terminal-initialization (selected-frame) "screen"))
+
 ;; Don't disable any commands.
 
 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
 (setq next-line-add-newlines nil)      ;Don't add weird newlines
 (setq split-height-threshold nil)      ;Reuse windows where sensible
 (setq display-buffer-reuse-frames nil  ;Don't confuse me by showing buffers
-      iswitchb-default-method 'samewindow) ;in other random frames
+      iswitchb-default-method 'samewindow ;in other random frames
+      ido-default-file-method 'selected-window
+      ido-default-buffer-method 'selected-window)
+(setq ido-enable-flex-matching t
+      ido-everywhere t
+      ido-confirm-unique-completion t
+      ido-use-filename-at-point nil
+      ido-auto-merge-work-directories-length -1)
+(setq pcomplete-cycle-completions nil  ;Who thought that was a good idea?
+      eshell-cmpl-cycle-completions nil)
 (setq dired-deletion-confirmer         ;Make deletion easier in dired
       (symbol-function 'y-or-n-p)
       dired-listing-switches "-alF"    ;Do `ls -F' things in dired windows
 (setq read-quoted-char-radix 16)       ;C-q HEX-STUFF [RET]
 (setq case-fold-file-names nil)                ;Don't translate file names (grr...)
 (setq scroll-step 5)                   ;Don't scroll too much at a time
-(setq-default fill-column 77)          ;I use rather narrow windows
+(setq blink-cursor-blinks 0)           ;Keep blinking the cursor
+(setq-default fill-column mdw-text-width) ;I use rather narrow windows
+(setq reb-re-syntax 'string)           ;Enough backslashes even with this
 (setq-default comment-column 40)       ;Set a standard comment column
 (setq-default truncate-partial-width-windows nil
              truncate-lines t)
 (setq default-indicate-empty-lines t)
-(setq whitespace-style
-      '(trailing space-before-tab space-after-tab empty indentation face))
+(setq view-read-only t)
+(setq-default view-exit-action #'kill-buffer)
+(setq whitespace-style '(trailing empty indentation face lines-tail
+                        space-before-tab space-after-tab)
+      whitespace-line-column mdw-text-width)
 (setq woman-use-own-frame nil          ;Keep man pages somewhere sensible
       woman-fill-column 72)            ;Right margin position.
 (setq diff-switches "-u"               ;I like reading unified diffs
 (setq find-ls-option                   ;Build file lists efficiently
       '("-print0 | xargs -0r ls -ld" . "ld"))
 (setq bookmark-save-flag 0)            ;Save bookmarks automatically
+(setq vc-follow-symlinks t)
 (setq x-gtk-file-dialog-help-text nil)
 (setq Info-fontify-maximum-menu-size 100000)
 (setq set-mark-command-repeat-pop t)
   (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
   (setq uniquify-after-kill-buffer-p t))
 (transient-mark-mode t)
-(setq mark-even-if-inactive t)
+(setq mark-even-if-inactive t
+      shift-select-mode nil
+      delete-active-region nil
+      delete-selection-mode nil)
 (trap
   (tooltip-mode 0)
   (tool-bar-mode 0))
       w3m-use-cookies t)
 
 (eval-after-load "w3m"
-  '(let ((entries '(("application/pdf" "\\.pdf\\'" ("evince" file) nil)
-                   ("application/x-pdf" "\\.pdf\\'" ("evince" file) nil))))
+  '(let ((entries '(("application/pdf" "\\.pdf\\'" ("xdg-open" file) nil)
+                   ("application/x-pdf" "\\.pdf\\'" ("xdg-open" file) nil))))
      (dolist (e entries)
        (setq w3m-content-type-alist
             (cons e (remove* (car e) w3m-content-type-alist
 (setq appt-display-interval 3)
 (setq appt-message-warning-time 10)
 (and (not mdw-fast-startup)
-     (trap (appt-activate 1)))
+     (trap (require 'org)
+          (require 'bbdb)
+          (appt-activate 1)))
 
 ;; Org-mode agenda.
 
 (display-time)
 (column-number-mode 1)
 (trap
-  (if window-system
+  (if (and window-system (not mdw-fast-startup))
       (let ((calendar-view-diary-initially-flag t))
        (calendar))))
 
 
 (setq frame-background-mode (if mdw-black-background 'dark 'light)
       default-frame-alist
-      `((width . ,(if (>= emacs-major-version 21) 77 78))
+      `((width . ,(+ mdw-column-width
+                    (if (>= emacs-major-version 21) 0 1)))
        (height . 33)
        (vertical-scroll-bars . right)
        (cursor-type . bar)
        (cursor-color . "red")
        (background-mode . ,frame-background-mode))
       initial-frame-alist
-      `((width . ,(if (>= emacs-major-version 21) 77 78))
+      `((width . ,(+ mdw-column-width
+                    (if (>= emacs-major-version 21) 0 1)))
        (menu-bar-lines . ,(if window-system 1 0)))
       window-system-default-frame-alist
       '((pm (font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
             (background-color . "black")
             (foreground-color . "white"))
        (nil (menu-bar-lines . 0))))
+(let ((backg (frame-parameter nil 'background-color)))
+  (if (and backg window-system)
+      (push (cons 'background-color backg) default-frame-alist)))
 
 ;; Other frame fiddling.
 
 (trap
   (windmove-default-keybindings))
 (setq windmove-wrap-around t)
-(trap (iswitchb-mode))
+(trap (require 'ido) (ido-mode 1)
+      (require 'ido-ubiquitous) (ido-ubiquitous-mode 1)
+      (setq ido-cr+-max-items nil
+           ido-ubiquitous-command-overrides
+           (append ido-ubiquitous-command-overrides
+                   `((enable-old regexp ,(concat "\\`"
+                                                 "gtags-find-"
+                                                 "\\("    "tag"
+                                                       "\\|file"
+                                                       "\\|rtag"
+                                                       "\\|symbol"
+                                                 "\\)"
+                                                 "\\(" "\\|-other-window"
+                                                 "\\)"
+                                                 "\\'")))))
+      (setq magit-completing-read-function 'magit-ido-completing-read)
+      (require 'smex) (smex-initialize) (global-set-key [?\M-x] 'smex))
+
 (progn
+  (global-set-key [?\C-c ?\M-x] 'execute-extended-command)
   (global-set-key [?\e ?\e] 'mdw-wrong)
   (global-set-key [?\e ?\C-\] ?\C-\]] 'keyboard-escape-quit)
   (global-set-key [?\C-c ?w left] 'windmove-left)
   (global-set-key [?\C-c ?t ?i] 'timeclock-in)
   (global-set-key [?\C-c ?t ?c] 'timeclock-change)
   (global-set-key [?\C-c ?t ?o] 'timeclock-out)
-  (global-set-key [?\C-c ?t ?r] 'timeclock-reread-log)
+  (global-set-key [?\C-c ?t ?R] 'timeclock-reread-log)
   (global-set-key [?\C-c ?t ?w] 'timeclock-workday-remaining-string)
   (global-set-key [?\C-c ?t ?s] 'timeclock-status-string)
+  (global-set-key [?\C-c ?m ?m] 'magit-status)
+  (global-set-key [?\C-c ?m ?d] 'magit-dispatch-popup)
+  (global-set-key [?\C-c ?m ?w] 'magit-wip-log)
+  (global-set-key [?\C-c ?m ?r] 'magit-list-repositories)
+  (global-set-key [?\C-c ?m ?b] 'magit-blame)
+  (global-set-key [?\C-c ?p ?p] 'mdw-mpc-play-or-pause)
+  (global-set-key [?\C-c ?p ?s] 'mdw-mpc-stop)
+  (global-set-key [?\C-c ?p ?<] 'mdw-mpc-prev)
+  (global-set-key [?\C-c ?p ?>] 'mdw-mpc-next)
+  (global-set-key [?\C-c ?p ?+] 'mdw-mpc-louder)
+  (global-set-key [?\C-c ?p ?-] 'mdw-mpc-quieter)
+  (global-set-key [?\C-c ?p ??] 'mdw-mpc-now-playing)
+  (global-set-key [?\C-c ?t ?t] 'gtags-find-tag-from-here)
+  (global-set-key [?\C-c ?t ?.] 'gtags-find-tag)
+  (global-set-key [?\C-c ?t ?r] 'gtags-find-rtag)
+  (global-set-key [?\C-c ?t ?4 ?.] 'gtags-find-tag-other-window)
+  (global-set-key [?\C-c ?t ?,] 'gtags-pop-stack)
+  (global-set-key [?\C-c ?k] 'mdw-compile)
   (global-set-key [?\C-x ?3] 'mdw-split-window-horizontally)
   (global-set-key [?\M-#] 'calc-dispatch)
   (global-set-key [?\C-x ?/] 'auto-fill-mode)
   (global-set-key [?\C-c ?d ?a] 'devhelp-assistant-word-at-point)
   (global-set-key [f11] 'mdw-toggle-full-screen)
   (and (not mdw-fast-startup) (fboundp 'hippie-expand)
-       (global-set-key [?\M-/] 'hippie-expand)))
+       (global-set-key [?\M-?] 'hippie-expand)))
+
+(eval-after-load "hippie-exp"
+  '(setq hippie-expand-try-functions-list
+        (remove-if (lambda (name)
+                     (memq name '(try-expand-list
+                                  try-expand-list-all-buffers)))
+                   hippie-expand-try-functions-list)))
 
 (eval-after-load "dired"
   '(progn
      (trap (require 'dired-x))
      (and (fboundp 'dired-do-relsymlink)
          (define-key dired-mode-map [?\C-c ?\C-s] 'dired-do-relsymlink))))
+(setq dired-guess-shell-alist-user
+      '(("\\.pdf\\'" "mupdf")))
 
 (add-hook 'org-mode-hook
          #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
                          "\\)$")
                 . text-mode)
                ("\\.calc?$" . apcalc-mode)
-               ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
                ("/\\(s\\|sh\\)/" . arm-assembler-mode)
                ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
                ("\\.st$" . smalltalk-mode)
        TeXinfo-mode-hook tex-mode-hook latex-mode-hook
        texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
        lisp-mode-hook lisp-interaction-mode-hook makefile-mode-hook
-       inferior-lisp-mode-hook slime-repl-mode-hook
+       inferior-lisp-mode-hook slime-repl-mode-hook ielm-mode-hook
        sml-mode-hook haskell-mode-hook erlang-mode-hook
-       smalltalk-mode-hook rexx-mode-hook
+       smalltalk-mode-hook rexx-mode-hook lua-mode-hook
        arm-assembler-mode-hook))
 
 (global-font-lock-mode t)
   (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
   (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
   (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
-  (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
   (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
   (add-hook 'go-mode-hook 'mdw-fontify-go t)
   (add-hook 'rust-mode-hook 'mdw-fontify-rust t)
 
+  (add-hook 'lua-mode-hook 'mdw-fontify-lua t)
   (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
 
   (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
 (progn
   (setq-default py-indent-offset 2
                python-indent 2
+               python-indent-offset 2
                py-python-command-args
                `("-i" "-colors" ,(if mdw-black-background
                                      "Linux" "LightBG")))
   (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
   (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
   (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
+  (add-hook 'ielm-mode-hook 'mdw-fontify-lispy t)
   (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
   (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
   (add-hook 'inferior-lisp-mode-hook
 (setq TeX-output-view-style
       '(("^dvi$"
         ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
-        "%(o?)dvips -t landscape %d -o && evince %f")
+        "%(o?)dvips -t landscape %d -o && xdg-open %f")
        ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
-        "%(o?)dvips %d -o && evince %f")
+        "%(o?)dvips %d -o && xdg-open %f")
        ("^dvi$"
         ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
         "%(o?)xdvi %dS -paper a4r -s 0 %d")
        ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
        ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
        ("^dvi$" "." "%(o?)xdvi %dS %d")
-       ("^pdf$" "." "evince %o")
-       ("^html?$" "." "netscape %o")))
+       ("^pdf$" "." "xdg-open %o")
+       ("^html?$" "." "sensible-browser %o")))
+
+(setq TeX-view-program-list
+      '(("mupdf" "mupdf %o" (mode-io-correlate " %(outpage)"))))
 
 (setq TeX-view-program-selection
       '(((output-dvi style-pstricks) "dvips and gv")
        (output-dvi "xdvi")
-       (output-pdf "Evince")
-       (output-html "xdg-open")))
+       (output-pdf "mupdf")
+       (output-html "sensible-browser")))
 
 (setq TeX-open-quote "\""
       TeX-close-quote "\"")