Open main menu

Changes

commented code
== With use-package ==View a demostration [https://asciinema.org/a/657842 here].<pre>;;; Till Mueller, 2024-05-04. No copyright. ;; AUCTeX has good support for LaTeX out-of-the-box. For ConTeXt, not;; so much.;;;; Fortunately much of the functionality, in particular;; LaTeX-math-mode can be reused as-is in ConTeXt mode.;; LaTeX-math-mode is a minor mode with easy access to TeX math;; macros. Such as ` a for \alpha. You can define custom shortcuts;; via LaTeX-math-list as well.;;;; The key is to tweak texmathp-tex-commands for recognizing math;; environment in a ConTeXt document, or else LaTeX-math will not;; work. (use-package context :hook ((ConTeXt-mode . turn-on-reftex)  ;; personal preference (ConTeXt-mode . variable-pitch-mode)  ;; show \alpha as α and \mathbb{R} as ℝ (ConTeXt-mode . prettify-symbols-mode)  ;; shortcuts for symbols (ConTeXt-mode . LaTeX-math-mode))  :custom ;; AUCTeX defaults to mkii; change to iv for iv and lmtx (ConTeXt-Mark-version "IV")  ;; Enable electric left right brace (LaTeX-electric-left-right-brace t)  ;; Do not unprettify symbol at point (prettify-symbols-unprettify-at-point nil)  ;; Let AUCTeX properly detect formula environment as math mode (texmathp-tex-commands '(("\\startformula" sw-on) ("\\stopformula" sw-off)))  ;; Set PDF viewer (TeX-view-program-selection '((output-pdf "Zathura")))  ;; Don't as for permission, just save all files (TeX-save-query nil)  ;; Auto-save (TeX-auto-save t)  ;; Debug bad boxes and warnings after compilation via ;; C-c ` key (TeX-debug-bad-boxes t) (TeX-debug-warnings t)  ;; Electric inline math, (TeX-electric-math '("$" . "$"))  ;; Electric sub and superscript, inserts {} after ^ and _ ;; such as a^{}. (TeX-electric-sub-and-superscript t)  ;; RefTex (reftex-plug-into-AUCTeX t)  ;; Customize keyboard shortcuts for TeX math macros (LaTeX-math-list '(("o r" "mathbb{R}" nil nil) ("o Q" "qquad" nil nil) ("o q" "quad" nil nil) ("o n" "mathbb{N}" nil nil) (?= "coloneq" nil nil) ("o c" "mathbb{C}" nil nil)))  :bind ;; Electric \left(\right) \left[\right] \left\{\right\} ;; only left brace; there is no right electric brace function (:map ConTeXt-mode-map ("(" . LaTeX-insert-left-brace)) (:map ConTeXt-mode-map ("[" . LaTeX-insert-left-brace)) (:map ConTeXt-mode-map ("{" . LaTeX-insert-left-brace))  :config (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)  ;; Prettify symbols mode, customizable. (with-eval-after-load "tex-mode" (dolist (symb '(("\\colon" . ?:) ("\\mathbb{C}" . ?ℂ) ("\\mathbb{K}" . ?𝕂))) (add-to-list 'tex--prettify-symbols-alist symb))))</pre> == Help with delimters delimiters and math mode ==
These customizations are mostly for faster insertion of special characters (and math mode).
(backward-char 5))
  (add-hook 'ConTeXt-mode-hook '(lambda () (defun local-set-key "\C-cnr" 'context-insert-nattab-row) (local-set-key "\C-cnc" 'context-insert-nattab-column) (local-set-key "\C-cnn" 'context-insert-nattab)))</pre> == Help with FLOWcharts (from m-cells (nchart.tex)== <pre> ;; Johan Sandblom 2006. No copyright.(defun context-FLOW-shift-cells (x y beg end) "Shifts FLOW cells in region right and down" (interactive "nRight: \nnDown: \nr") (save-excursion (goto-char beg) (while (search-forward-regexp "{\\([0-9]+\\),\\([0-9]+\\)}" end t) (replace-match (concat "{" (number-to-string (+ (string-to-number (match-string 1)) x)) "," (number-to-string (+ (string-to-01number (match-28string 2)) y)) "}") nil nil)))) (defun context-FLOW-insert-cells (%optional n)
"Insert a FLOWchart cell"
(interactive "nNumber of cells: \nP") (if (not (bolp)) (newline))
(let ((x 1))
(while (&lt;= x (if nn 1))
(insert "\\startFLOWcell\n")
(insert " \\name {}\n")
(insert "\\stopFLOWcell\n")
(setq x (1+ x)))))
 
(add-hook 'ConTeXt-mode-hook
'(lambda ()
(define-key (current-local-map) "\C-cnF" 'context-FLOW-insert-FLOW-cells) (define-key (current-local-set-key map) "\C-cnrcnS" 'context-insertFLOW-shift-cells)))</pre> == Metapost-mode and r-mode (from ESS, http://ess.r-project.org) in context-mode with mmm-mode == <pre>;; Johan Sandblom. No copyright.(require 'mmm-mode)(setq mmm-global-mode 'maybe)(setq mmm-submode-nattabdecoration-rowlevel 2) (localmmm-setadd-key "\Cgroup 'context-cnc" plus '((context-insertR :submode r-mode :face mmm-comment-nattabsubmode-columnface :front ".*\\\\startR\\w*\\({\\w*}\\|\\[\\w*\\]\\|\\)\\W*" :back ".*\\\\stopR") (localcontext-MP :submode metapost-mode :face mmm-code-setsubmode-key face :front ".*\\\\start\\w*MP\\w*\\({\\w*}\\|\\[\\w*\\]\\|\\)\\W*" :back ".*\\\\stop\\Cw*MP") ))(add-to-list 'mmm-mode-ext-classes-cnn" alist '(context-insertmode nil context-nattab)plus))
</pre>
 
 
[[Category:Text Editors]]
11

edits