(select-window win)))
(defun mdw-set-frame-width (columns &optional width)
+ "Set the current frame to be the correct width for COLUMNS columns.
+
+If WIDTH is non-nil, then it provides the width for the new columns. (This
+can be set interactively with a prefix argument.)"
(interactive "nColumns:
P")
(setq width (if width (prefix-numeric-value width)
This is sadly necessary because Emacs 26 is broken in this regard.")
+(defvar mdw-frame-colour-alist
+ '((black . ("#000000" . "#ffffff"))
+ (red . ("#2a0000" . "#ffffff"))
+ (green . ("#002a00" . "#ffffff"))
+ (blue . ("#00002a" . "#ffffff")))
+ "*Alist mapping symbol names to (FOREGROUND . BACKGROUND) colour pairs.")
+
+(defun mdw-set-frame-colour (colour &optional frame)
+ (interactive "xColour name or (FOREGROUND . BACKGROUND) pair:
+")
+ (when (and colour (symbolp colour))
+ (let ((entry (assq colour mdw-frame-colour-alist)))
+ (unless entry (error "Unknown colour `%s'" colour))
+ (setf colour (cdr entry))))
+ (set-frame-parameter frame 'background-color (car colour))
+ (set-frame-parameter frame 'foreground-color (cdr colour)))
+
;; Don't raise windows unless I say so.
(defvar mdw-inhibit-raise-frame nil
(eval-after-load "ox-latex"
'(setq org-latex-classes (append mdw-org-latex-defs org-latex-classes)
+ org-latex-caption-above nil
org-latex-default-packages-alist '(("AUTO" "inputenc" t)
("T1" "fontenc" t)
("" "fixltx2e" nil)
(unless mdw-inhibit-rename-buffer
(let ((buffer (get-file-buffer from)))
(when buffer
- (let ((to (if (not (directory-name-p to)) to
+ (let ((to (if (not (string= (file-name-nondirectory to) "")) to
(concat to (file-name-nondirectory from)))))
(with-current-buffer buffer
(set-visited-file-name to nil t)))))))
(insert-file-contents "/proc/cpuinfo")
(buffer-string)
(count-matches "^processor\\s-*:"))))
- (format "make -j%d -k" (* 2 ncpu))))
+ (format "nice make -j%d -k" (* 2 ncpu))))
(defun mdw-compilation-buffer-name (mode)
(concat "*" (downcase mode) ": "
(pad . ,(or mat 2))))))
;;;--------------------------------------------------------------------------
+;;; Printing.
+
+;; Teach PostScript about a condensed variant of Courier. I'm using 85% of
+;; the usual width, which happens to match `mdwfonts', and David Carlisle's
+;; `pslatex'. (Once upon a time, I used 80%, but decided consistency with
+;; `pslatex' was useful.)
+(setq ps-user-defined-prologue "
+/CourierCondensed /Courier
+/CourierCondensed-Bold /Courier-Bold
+/CourierCondensed-Oblique /Courier-Oblique
+/CourierCondensed-BoldOblique /Courier-BoldOblique
+ 4 { findfont [0.85 0 0 1 0 0] makefont definefont pop } repeat
+")
+
+;; Hack `ps-print''s settings.
+(eval-after-load 'ps-print
+ '(progn
+
+ ;; Notice that the comment-delimiters should be in italics too.
+ (pushnew 'font-lock-comment-delimiter-face ps-italic-faces)
+
+ ;; Select more suitable colours for the main kinds of tokens. The
+ ;; colours set on the Emacs faces are chosen for use against a dark
+ ;; background, and work very badly on white paper.
+ (ps-extend-face '(font-lock-comment-face "darkgreen" nil italic))
+ (ps-extend-face '(font-lock-comment-delimiter-face "darkgreen" nil italic))
+ (ps-extend-face '(font-lock-string-face "RoyalBlue4" nil))
+ (ps-extend-face '(mdw-punct-face "sienna" nil))
+ (ps-extend-face '(mdw-number-face "OrangeRed3" nil))
+
+ ;; Teach `ps-print' about my condensed varsions of Courier.
+ (setq ps-font-info-database
+ (append '((CourierCondensed
+ (fonts (normal . "CourierCondensed")
+ (bold . "CourierCondensed-Bold")
+ (italic . "CourierCondensed-Oblique")
+ (bold-italic . "CourierCondensed-BoldOblique"))
+ (size . 10.0)
+ (line-height . 10.55)
+ (space-width . 5.1)
+ (avg-char-width . 5.1)))
+ (cl-remove 'CourierCondensed ps-font-info-database
+ :key #'car)))))
+
+;; Arrange to strip overlays from the buffer before we print . This will
+;; prevent `flyspell' from interfering with the printout. (It would be less
+;; bad if `ps-print' could merge the `flyspell' overlay face with the
+;; underlying `font-lock' face, but it can't (and that seems hard). So
+;; instead we have this hack.
+;;
+;; The basic trick is to copy the relevant text from the buffer being printed
+;; into a temporary buffer and... just print that. The text properties come
+;; with the text and end up in the new buffer, and the overlays get lost
+;; along the way. Only problem is that the headers identifying the file
+;; being printed get confused, so remember the original buffer and reinstate
+;; it when constructing the headers.
+(defvar mdw-printing-buffer)
+
+(defadvice ps-generate-header
+ (around mdw-use-correct-buffer () activate compile)
+ "Print the correct name of the buffer being printed."
+ (with-current-buffer mdw-printing-buffer
+ ad-do-it))
+
+(defadvice ps-generate
+ (around mdw-strip-overlays (buffer from to genfunc) activate compile)
+ "Strip overlays -- in particular, from `flyspell' -- before printout."
+ (with-temp-buffer
+ (let ((mdw-printing-buffer buffer))
+ (insert-buffer-substring buffer from to)
+ (ad-set-arg 0 (current-buffer))
+ (ad-set-arg 1 (point-min))
+ (ad-set-arg 2 (point-max))
+ ad-do-it)))
+
+;;;--------------------------------------------------------------------------
;;; Other common declarations.
;; Common mode settings.
(((class color)) :background "cyan")
(t :inverse-video t))
+(mdw-define-face viper-minibuffer-emacs (t nil))
+(mdw-define-face viper-minibuffer-insert (t nil))
+(mdw-define-face viper-minibuffer-vi (t nil))
+(mdw-define-face viper-replace-overlay
+ (((min-colors 64)) :background "darkred")
+ (((class color)) :background "red")
+ (t :inverse-video t))
+(mdw-define-face viper-search (t :inherit isearch))
+
(mdw-define-face holiday-face
(t :background "red"))
(mdw-define-face calendar-today-face
(statement-cont . +)
(statement-case-intro . +)))
-(mdw-define-c-style mdw-trustonic-basic-c (mdw-c)
+(mdw-define-c-style mdw-trustonic-c (mdw-c)
(c-basic-offset . 4)
- (comment-column . 0)
(c-indent-comment-alist (anchored-comment . (column . 0))
(end-block . (space . 1))
(cpp-end-block . (space . 1))
(other . (space . 1)))
(c-offsets-alist (access-label . -2)))
-(mdw-define-c-style mdw-trustonic-c (mdw-trustonic-basic-c)
+(mdw-define-c-style mdw-trustonic-alec-c (mdw-trustonic-c)
+ (comment-column . 0)
(c-offsets-alist (arglist-cont-nonempty . mdw-c-indent-arglist-nested)))
(defun mdw-set-default-c-style (modes style)
(add-hook 'icon-mode-hook 'mdw-fontify-icon t))
;;;--------------------------------------------------------------------------
+;;; Fortran mode.
+
+(defun mdw-fontify-fortran-common ()
+ (let ((fortran-keywords
+ (mdw-regexps "access"
+ "assign"
+ "associate"
+ "backspace"
+ "blank"
+ "block\\s-*data"
+ "call"
+ "case"
+ "character"
+ "class"
+ "close"
+ "common"
+ "complex"
+ "continue"
+ "critical"
+ "data"
+ "dimension"
+ "do"
+ "double\\s-*precision"
+ "else" "elseif" "elsewhere"
+ "end"
+ "endblock" "endblockdata"
+ "endcritical"
+ "enddo"
+ "endinterface"
+ "endmodule"
+ "endprocedure"
+ "endprogram"
+ "endselect"
+ "endsubmodule"
+ "endsubroutine"
+ "endtype"
+ "endwhere"
+ "endenum"
+ "end\\s-*file"
+ "endforall"
+ "endfunction"
+ "endif"
+ "entry"
+ "enum"
+ "equivalence"
+ "err"
+ "external"
+ "file"
+ "fmt"
+ "forall"
+ "form"
+ "format"
+ "function"
+ "go\\s-*to"
+ "if"
+ "implicit"
+ "in" "inout"
+ "inquire"
+ "include"
+ "integer"
+ "interface"
+ "intrinsic"
+ "iostat"
+ "len"
+ "logical"
+ "module"
+ "open"
+ "out"
+ "parameter"
+ "pause"
+ "procedure"
+ "program"
+ "precision"
+ "program"
+ "read"
+ "real"
+ "rec"
+ "recl"
+ "return"
+ "rewind"
+ "save"
+ "select" "selectcase" "selecttype"
+ "status"
+ "stop"
+ "submodule"
+ "subroutine"
+ "then"
+ "to"
+ "type"
+ "unit"
+ "where"
+ "write"))
+ (fortran-operators (mdw-regexps "and"
+ "eq"
+ "eqv"
+ "false"
+ "ge"
+ "gt"
+ "le"
+ "lt"
+ "ne"
+ "neqv"
+ "not"
+ "or"
+ "true"))
+ (fortran-intrinsics (mdw-regexps "abs" "dabs" "iabs" "cabs"
+ "atan" "datan" "atan2" "datan2"
+ "cmplx"
+ "conjg"
+ "cos" "dcos" "ccos"
+ "dble"
+ "dim" "idim"
+ "exp" "dexp" "cexp"
+ "float"
+ "ifix"
+ "aimag"
+ "int" "aint" "idint"
+ "alog" "dlog" "clog"
+ "alog10" "dlog10"
+ "max"
+ "amax0" "amax1"
+ "max0" "max1"
+ "dmax1"
+ "min"
+ "amin0" "amin1"
+ "min0" "min1"
+ "dmin1"
+ "mod" "amod" "dmod"
+ "sin" "dsin" "csin"
+ "sign" "isign" "dsign"
+ "sngl"
+ "sqrt" "dsqrt" "csqrt"
+ "tanh"))
+ (preprocessor-keywords
+ (mdw-regexps "assert" "define" "elif" "else" "endif" "error"
+ "ident" "if" "ifdef" "ifndef" "import" "include"
+ "line" "pragma" "unassert" "undef" "warning")))
+ (setq font-lock-keywords-case-fold-search t
+ font-lock-keywords
+ (list
+
+ ;; Fontify include files as strings.
+ (list (concat "^[ \t]*\\#[ \t]*" "include"
+ "[ \t]*\\(<[^>]+>?\\)")
+ '(1 font-lock-string-face))
+
+ ;; Preprocessor directives are `references'?.
+ (list (concat "^\\([ \t]*#[ \t]*\\(\\("
+ preprocessor-keywords
+ "\\)\\>\\|[0-9]+\\|$\\)\\)")
+ '(1 font-lock-keyword-face))
+
+ ;; Set up the keywords defined above.
+ (list (concat "\\<\\(" fortran-keywords "\\)\\>")
+ '(0 font-lock-keyword-face))
+
+ ;; Set up the `.foo.' operators.
+ (list (concat "\\.\\(" fortran-operators "\\)\\.")
+ '(0 font-lock-keyword-face))
+
+ ;; Set up the intrinsic functions.
+ (list (concat "\\<\\(" fortran-intrinsics "\\)\\>")
+ '(0 font-lock-variable-name-face))
+
+ ;; Numbers.
+ (list (concat "\\(" "\\<" "[0-9]+" "\\(\\.[0-9]*\\)?"
+ "\\|" "\\.[0-9]+"
+ "\\)"
+ "\\(" "[de]" "[+-]?" "[0-9]+" "\\)?"
+ "\\(" "_" "\\sw+" "\\)?"
+ "\\|" "b'[01]*'" "\\|" "'[01]*'b"
+ "\\|" "b\"[01]*\"" "\\|" "\"[01]*\"b"
+ "\\|" "o'[0-7]*'" "\\|" "'[0-7]*'o"
+ "\\|" "o\"[0-7]*\"" "\\|" "\"[0-7]*\"o"
+ "\\|" "[xz]'[0-9a-f]*'" "\\|" "'[0-9a-f]*'[xz]"
+ "\\|" "[xz]\"[0-9a-f]*\"" "\\|" "\"[0-9a-f]*\"[xz]")
+ '(0 mdw-number-face))
+
+ ;; Any anything else is punctuation.
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face))))
+
+ (modify-syntax-entry ?/ "." font-lock-syntax-table)
+ (modify-syntax-entry ?< ".")
+ (modify-syntax-entry ?> ".")))
+
+(defun mdw-fontify-fortran () (mdw-fontify-fortran-common))
+(defun mdw-fontify-f90 () (mdw-fontify-fortran-common))
+
+(setq fortran-do-indent 2
+ fortran-if-indent 2
+ fortran-structure-indent 2
+ fortran-comment-line-start "*"
+ fortran-comment-indent-style 'relative
+ fortran-continuation-string "&"
+ fortran-continuation-indent 4)
+
+(setq f90-do-indent 2
+ f90-if-indent 2
+ f90-program-indent 2
+ f90-continuation-indent 4
+ f90-smart-end-names nil
+ f90-smart-end 'no-blink)
+
+(progn
+ (add-hook 'fortran-mode-hook 'mdw-misc-mode-config t)
+ (add-hook 'fortran-mode-hook 'mdw-fontify-fortran t)
+ (add-hook 'f90-mode-hook 'mdw-misc-mode-config t)
+ (add-hook 'f90-mode-hook 'mdw-fontify-f90 t))
+
+;;;--------------------------------------------------------------------------
;;; Assembler mode.
(defun mdw-fontify-asm ()
(current-column))))
;; Don't really care about this.
- (when (and (eq lisp-indent-backquote-substitution-mode 'corrected))
+ (when (and (boundp 'lisp-indent-backquote-substitution-mode)
+ (eq lisp-indent-backquote-substitution-mode 'corrected))
(save-excursion
(goto-char (elt state 1))
(cl-incf loop-indentation
(setq ad-return-value
(list
- (cond ((not (lisp-extended-loop-p (elt state 1)))
+ (cond ((condition-case ()
+ (save-excursion
+ (goto-char (elt state 1))
+ (forward-char 1)
+ (forward-sexp 2)
+ (backward-sexp 1)
+ (not (looking-at "\\(:\\|\\sw\\)")))
+ (error nil))
(+ baseline-indent lisp-simple-loop-indentation))
((looking-at "^\\s-*\\(:?\\sw+\\|;\\)")
(+ baseline-indent lisp-loop-keyword-indentation))