;;; ... -*- lexical-binding: t -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Programming support ;;; ;;; Sets up general programming options and loading of language modes ;;; Non-specific setup (use-package flycheck :init (global-flycheck-mode)) ;; Blink those parens (if (require 'paren nil t) (show-paren-mode t)) ;; Adapt those fills ;; (if (require 'filladapt nil t) ;; (progn ;; ;; Disable built-in adaptive filling ;; (setq adaptive-fill-mode nil) ;; ;; This is a little weird. filladapt overloads a bunch of ;; ;; autofill's functions, so just by loading it and setting the ;; ;; mode variable it will come to life. The modeline won't be ;; ;; updated unless turn-on-filladapt-mode is called from every ;; ;; buffer. ;; (setq filladapt-mode-line-string " F*"))) ;; Tabs are evil. Use spaces to indent (setq-default indent-tabs-mode nil) ;; Autoindent after a line (global-set-key "\C-m" 'newline-and-indent) ;; Self-explanatory (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) (setq ;; Make auto-fill in programming modes on affect comments comment-auto-fill-only-comments t ;; When commenting a block with a block-style comment, use a single ;; multi-line comment where the start and end are on their own lines comment-style 'extra-line) ;; Spiff up compilation mode. It would be even cooler if the buffer ;; automatically went away when compilation finished with no errors ;; (or possibly never appeared if there were no errors). See ;; compilation-finish-functions hook. Also, it would be nice if it ;; automatically scrolled until it hit the first error (Use ;; compilation-filter-hook?), or at least scrolled with the output and ;; then jumped the point to the first error. (compilation-next-error ;; 1 nil (point-min)) will move point to the first error in the ;; compilation buffer, or give a Lisp error if there are none. (setq compilation-window-height 10 ;; compilation-context-lines 1 compilation-scroll-output t) (load "compile-improved.el") ;;; Set up individual language modes (require 'drkp-features) ;; C/C++ is too scary to fit here (load "drkp-cc") ;; Java (drkp:autoload-mode 'jde-mode "jde-mode" "\\.java$") ;; Python (drkp:add-mode-features 'python-mode-hook '( ;filladapt flyspell-prog)) ;; MIT Scheme ;; (drkp:autoload-mode 'scheme-mode "xscheme" "\\.scm$") ;; (drkp:add-mode-features 'scheme-mode-hook '(autofill flyspell-prog)) ;; PLT Scheme (defun scheme-send-buffer () (interactive) (scheme-send-region (point-min) (point-max))) (defmodefeature quack-send-buffer (local-set-key "\C-c\C-c" 'scheme-send-buffer) ;; Quack inadvertently changes the semantics of scheme-proc in bad ;; ways. It advises it so that, if no current inferior Scheme ;; buffer exists, it starts a new one. However, it has the ;; side-effect of switching to this new buffer. This break ;; functions like scheme-send-region, which then try to read from ;; the Scheme process buffer instead of the buffer in which they ;; were called. (defadvice scheme-proc (around drkp-ad-fix-quack first nil activate) (save-current-buffer ad-do-it))) (drkp:autoload-mode 'scheme-mode "quack" "\\.scm$") (drkp:add-mode-features 'scheme-mode-hook '(autofill ;filladapt flyspell-prog quack-send-buffer)) (setq quack-fontify-style 'plt ;; Alas, this only works with plt-style fontification quack-pretty-lambda-p t quack-run-scheme-always-prompts-p t quack-smart-open-paren-p t quack-default-program "scheme") ;; Lisp (drkp:add-mode-features '(lisp-mode-hook emacs-lisp-mode-hook) '(autofill ;filladapt flyspell-prog)) ;; Shell (drkp:add-mode-features 'sh-mode-hook '(autofill ;filladapt flyspell-prog)) ;; HTML, text, and Subversion log messages (drkp:add-mode-features '(html-mode-hook text-mode-hook) '(autofill flyspell-full)) (drkp:add-mode-features 'text-mode-hook '(plain-newline ;filladapt )) (when (require 'svn-msg-load nil t) (require 'svnci-load nil t) (setq svnci-revert-buffers t)) ;; Java ;; JDE is big and scary, so it gets its own whole file (load "drkp-jde.el") ;; LaTeX ;; This is surprisingly complicated, so it gets its own file too. (load "drkp-latex.el") ;; XML (when (load "nxml-mode/rng-auto" t) (add-to-list 'auto-mode-alist '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)) ;; Based on http://www.emacswiki.org/cgi-bin/wiki/NxmlMode (fset 'xml-mode 'nxml-mode) (fset 'html-mode 'nxml-mode) (if (boundp 'magic-mode-alist) ;; Emacs 22 (add-to-list 'magic-mode-alist '("<\\?xml " . nxml-mode)) (add-hook 'hack-local-variables-hook (lambda () (save-excursion (goto-char (point-min)) (when (looking-at "^<\\?xml ") (nxml-mode))))))) ;; P4 (drkp:autoload-mode 'p4-mode "p4-mode" "\\.p4$") ;; Puppet (use-package puppet-mode :mode "\\.pp\\'") (add-to-list 'exec-path "/opt/puppetlabs/bin") (with-eval-after-load 'flycheck (add-to-list 'flycheck-checkers 'puppet-parser) (add-to-list 'flycheck-checkers 'puppet-lint) (flycheck-add-next-checker 'puppet-parser '(warning . puppet-lint))) (if (file-executable-p "/opt/puppetlabs/bin/puppet-languageserver") (use-package eglot :ensure nil ;; built-in in recent Emacs :hook ((puppet-mode . eglot-ensure)) :config (add-to-list 'eglot-server-programs '((puppet-mode) "/opt/puppetlabs/puppet/bin/puppet-languageserver" "--stdio")) ;; Optional: ask for more helpful features from the server (setq eglot-workspace-configuration '(:puppet (:editorService (:formatOnType t :hover t :codeActions t))))))