Difference between revisions of "Emacs rc file"
From Tech
Jump to navigationJump to search (Created page with " <nowiki> ;;Remove trailing whitespace before saving a file: (add-hook 'write-file-hooks 'delete-trailing-whitespace) ;;Don't use tabs: (setq-default indent-tabs-mode nil);...") |
|||
| Line 45: | Line 45: | ||
:tail-mode 'host) |
:tail-mode 'host) |
||
| − | ;; 3. Define the LaTeX Inner Mode (.. math::) |
+ | ;; 3. Define the LaTeX Inner Mode (.. math::) |
(define-innermode poly-rst-math-innermode |
(define-innermode poly-rst-math-innermode |
||
:mode 'latex-mode |
:mode 'latex-mode |
||
| Line 54: | Line 54: | ||
;; 4. Define the Combined Mode |
;; 4. Define the Combined Mode |
||
| − | ;; Note: We added 'poly-rst-math-innermode' to the list below |
||
(define-polymode poly-rst-mixed-mode |
(define-polymode poly-rst-mixed-mode |
||
:hostmode 'poly-rst-hostmode |
:hostmode 'poly-rst-hostmode |
||
Latest revision as of 16:19, 19 November 2025
;;Remove trailing whitespace before saving a file:
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
;;Don't use tabs:
(setq-default indent-tabs-mode nil);
;; In Makefiles you do want tabs, so add in the Makefiles themelves:
;; # Local Variables:
;; # indent-tabs-mode: t
;; # End:
;; Normally, when the cursor moves just one line below or aboev
;; the visable edit window, the window moves many lines (half
;; the visable area). With this, it just moves one line.
(setq scroll-step 1)
;; -------------------------
;; POLYMODE CONFIGURATION
;; -------------------------
;;;Steps to enable the polymode emacs package:
;;;
;;(require 'package)
;;(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;;(package-initialize)
;;;;in emacs, type:
;;;; M-x package-refresh-contents [ENTER]
;;;; M-x package-install [ENTER] polymode [ENTER]
(require 'polymode)
;; 1. Define the Host Mode (RST)
(define-hostmode poly-rst-hostmode :mode 'rst-mode)
;; 2. Define the Python Inner Mode (.. plot::)
(define-innermode poly-rst-plot-innermode
:mode 'python-mode
:head-matcher "^\\.\\. plot::.*$"
:tail-matcher "^[^ \t\n]"
:head-mode 'host
:tail-mode 'host)
;; 3. Define the LaTeX Inner Mode (.. math::)
(define-innermode poly-rst-math-innermode
:mode 'latex-mode
:head-matcher "^\\.\\. math::.*$"
:tail-matcher "^[^ \t\n]"
:head-mode 'host
:tail-mode 'host)
;; 4. Define the Combined Mode
(define-polymode poly-rst-mixed-mode
:hostmode 'poly-rst-hostmode
:innermodes '(poly-rst-plot-innermode poly-rst-math-innermode))
;; 5. Auto-activate this mode for .rst files
(add-to-list 'auto-mode-alist '("\\.rst\\'" . poly-rst-mixed-mode))