(set-frame-parameter frame 'menu-bar-lines 0)
(set-frame-parameter frame 'menu-bar-lines old)))
+;; Page motion.
+
+(defun mdw-fixup-page-position ()
+ (unless (eq (char-before (point)) ?\f)
+ (forward-line 0)))
+
+(defadvice backward-page (after mdw-fixup compile activate)
+ (mdw-fixup-page-position))
+(defadvice forward-page (after mdw-fixup compile activate)
+ (mdw-fixup-page-position))
+
;; Splitting windows.
(unless (fboundp 'scroll-bar-columns)
sb-width))
(mdw-divvy-window width)))
+(defvar mdw-frame-width-fudge
+ (cond ((<= emacs-major-version 20) 1)
+ ((= emacs-major-version 26) 3)
+ (t 0))
+ "The number of extra columns to add to the desired frame width.
+
+This is sadly necessary because Emacs 26 is broken in this regard.")
+
;; Don't raise windows unless I say so.
(defvar mdw-inhibit-raise-frame nil
(months ["Chaos" "Discord" "Confusion"
"Bureaucracy" "Aftermath"])
(day-count [0 31 59 90 120 151 181 212 243 273 304 334])
- (year (- (extract-calendar-year date) 1900))
- (month (1- (extract-calendar-month date)))
- (day (1- (extract-calendar-day date)))
+ (year (- (calendar-extract-year date) 1900))
+ (month (1- (calendar-extract-month date)))
+ (day (1- (calendar-extract-day date)))
(julian (+ (aref day-count month) day))
(dyear (+ year 3066)))
(if (and (= month 1) (= day 28))
(let ((mdw-diary-for-org-mode-p t))
ad-do-it))
+(defvar diary-time-regexp nil)
+
(defadvice diary-add-to-list (before mdw-trim-leading-space compile activate)
"Trim leading space from the diary entry string."
(save-match-data
This is used by advice on `switch-to-buffer-other-frame' to inhibit finding
buffers in random frames.")
+(setq display-buffer--other-frame-action
+ '((display-buffer-reuse-window display-buffer-pop-up-frame)
+ (reusable-frames . nil)
+ (inhibit-same-window . t)))
+
(defadvice walk-windows (around mdw-inhibit activate)
"If `mdw-inhibit-walk-windows' is non-nil, then do nothing."
(and (not mdw-inhibit-walk-windows)
(delete-region (+ (match-beginning 0) 2) (point))
(setq string (buffer-substring (point) (+ (point) size)))
(delete-region (point) (+ (point) size))
- (insert (format "%S" (mm-subst-char-in-string ?\n ?\s string)))
+ (insert (format "%S" (subst-char-in-string ?\n ?\s string)))
;; [mdw] missing from upstream
(backward-char 1))
(beginning-of-line)
'(defalias 'nnimap-transform-headers
(symbol-function 'mdw-nnimap-transform-headers)))
+(defadvice gnus-other-frame (around mdw-hack-frame-width compile activate)
+ "Always arrange for mail/news frames to be 80 columns wide."
+ (let ((default-frame-alist (cons `(width . ,(+ 80 mdw-frame-width-fudge))
+ (cl-delete 'width default-frame-alist
+ :key #'car))))
+ ad-do-it))
+
+;; Preferred programs.
+
+(setq mailcap-user-mime-data
+ '(((type . "application/pdf") (viewer . "mupdf %s"))))
+
;;;--------------------------------------------------------------------------
;;; Utility functions.
(set (make-local-variable 'mdw-do-misc-mode-hacking) t)
(local-set-key [C-return] 'newline)
(make-local-variable 'page-delimiter)
- (setq page-delimiter "\f\\|^.*-\\{6\\}.*$")
+ (setq page-delimiter (concat "^" "\f"
+ "\\|" "^"
+ ".\\{0,4\\}"
+ "-\\{5\\}"
+ "\\(" " " ".*" " " "\\)?"
+ "-+"
+ ".\\{0,2\\}"
+ "$"))
(setq comment-column 40)
(auto-fill-mode 1)
(setq fill-column mdw-text-width)
(((type w32)) :family "courier new" :height 85)
(((type x)) :family "6x13" :foundry "trad" :height 130)
(t :foreground "white" :background "black"))
-(if (mdw-emacs-version-p 23)
- (mdw-define-face variable-pitch
- (((type x)) :family "sans" :height 100))
- (mdw-define-face variable-pitch
- (((type x)) :family "helvetica" :height 90)))
+(mdw-define-face fixed-pitch-serif
+ (((type w32)) :family "courier new" :height 85 :weight bold)
+ (((type x)) :family "6x13" :foundry "trad" :height 130 :weight bold)
+ (t :foreground "white" :background "black" :weight bold))
+(mdw-define-face variable-pitch
+ (((type x)) :family "helvetica" :height 120))
(mdw-define-face region
(((min-colors 64)) :background "grey30")
(((class color)) :background "blue")
(mdw-define-face comint-highlight-input
(t nil))
+(mdw-define-face Man-underline
+ (((type tty)) :underline t)
+ (t :slant italic))
+
(mdw-define-face ido-subdir
(t :foreground "cyan" :weight bold))
mdw-point-overlay-mode
(lambda () (if (not (minibufferp)) (mdw-point-overlay-mode t))))
+(defvar mdw-terminal-title-alist nil)
+(defun mdw-update-terminal-title ()
+ (when (let ((term (frame-parameter nil 'tty-type)))
+ (and term (string-match "^xterm" term)))
+ (let* ((tty (frame-parameter nil 'tty))
+ (old (assoc tty mdw-terminal-title-alist))
+ (new (format-mode-line frame-title-format)))
+ (unless (and old (equal (cdr old) new))
+ (if old (rplacd old new)
+ (setq mdw-terminal-title-alist
+ (cons (cons tty new) mdw-terminal-title-alist)))
+ (send-string-to-terminal (concat "\e]2;" new "\e\\"))))))
+
+(add-hook 'post-command-hook 'mdw-update-terminal-title)
+
;;;--------------------------------------------------------------------------
;;; C programming configuration.
;;;--------------------------------------------------------------------------
;;; Magit configuration.
-(setq magit-diff-refine-hunk 'all
+(setq magit-diff-refine-hunk 't
magit-view-git-manual-method 'man
magit-log-margin '(nil age magit-log-margin-width t 18)
magit-wip-after-save-local-mode-lighter ""
(set-window-dedicated-p (or window (selected-window)) nil))
;;;--------------------------------------------------------------------------
+;;; Man pages.
+
+;; Turn off `noip' when running `man': it interferes with `man-db''s own
+;; seccomp(2)-based sandboxing, which is (in this case, at least) strictly
+;; better.
+(defadvice Man-getpage-in-background
+ (around mdw-inhibit-noip (topic) compile activate)
+ "Inhibit the `noip' preload hack when invoking `man'."
+ (let* ((old-preload (getenv "LD_PRELOAD"))
+ (preloads (save-match-data (split-string old-preload ":")))
+ (any nil)
+ (filtered nil))
+ (while preloads
+ (let ((item (pop preloads)))
+ (if (save-match-data
+ (string-match "\\(/\\|^\\)noip\.so\\(:\\|$\\)" item))
+ (setq any t)
+ (push item filtered))))
+ (if any
+ (unwind-protect
+ (progn
+ (setenv "LD_PRELOAD"
+ (and filtered
+ (with-output-to-string
+ (setq filtered (nreverse filtered))
+ (let ((first t))
+ (while filtered
+ (if first (setq first nil)
+ (write-char ?:))
+ (write-string (pop filtered)))))))
+ ad-do-it)
+ (setenv "LD_PRELOAD" old-preload))
+ ad-do-it)))
+
+;;;--------------------------------------------------------------------------
;;; MPC configuration.
(eval-when-compile (trap (require 'mpc)))