X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/28082234ed759ee7725d4acc07a0efa075683253..3b361ad218cb4463349c91f10117c29972b8a24c:/el/dot-emacs.el diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 705143e..f164c40 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -1380,6 +1380,82 @@ case." (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. @@ -4623,7 +4699,8 @@ align the other subforms beneath it. Otherwise, indent them (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 @@ -4652,7 +4729,14 @@ align the other subforms beneath it. Otherwise, indent them (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))