diff options
Diffstat (limited to '.emacs.d')
| -rw-r--r-- | .emacs.d/lisp/lua-mode.el | 63 | ||||
| -rw-r--r-- | .emacs.d/lisp/markdown-mode.el | 49 | ||||
| -rw-r--r-- | .emacs.d/snippets/python-mode.statnett/format | 6 | ||||
| -rw-r--r-- | .emacs.d/snippets/python-mode.statnett/printf | 2 | ||||
| -rw-r--r-- | .emacs.d/snippets/python-mode/format | 6 | ||||
| -rw-r--r-- | .emacs.d/snippets/python-mode/printf | 2 |
6 files changed, 98 insertions, 30 deletions
diff --git a/.emacs.d/lisp/lua-mode.el b/.emacs.d/lisp/lua-mode.el index 2d6a2d5..4c543f5 100644 --- a/.emacs.d/lisp/lua-mode.el +++ b/.emacs.d/lisp/lua-mode.el | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | ;; Aaron Smith <aaron-lua@gelatinous.com>. | 12 | ;; Aaron Smith <aaron-lua@gelatinous.com>. |
| 13 | ;; | 13 | ;; |
| 14 | ;; URL: https://immerrr.github.io/lua-mode | 14 | ;; URL: https://immerrr.github.io/lua-mode |
| 15 | ;; Version: 20210802 | 15 | ;; Version: 20221027 |
| 16 | ;; Package-Requires: ((emacs "24.3")) | 16 | ;; Package-Requires: ((emacs "24.3")) |
| 17 | ;; | 17 | ;; |
| 18 | ;; This file is NOT part of Emacs. | 18 | ;; This file is NOT part of Emacs. |
| @@ -41,7 +41,8 @@ | |||
| 41 | 41 | ||
| 42 | ;; lua-mode provides support for editing Lua, including automatic | 42 | ;; lua-mode provides support for editing Lua, including automatic |
| 43 | ;; indentation, syntactical font-locking, running interactive shell, | 43 | ;; indentation, syntactical font-locking, running interactive shell, |
| 44 | ;; interacting with `hs-minor-mode' and online documentation lookup. | 44 | ;; Flymake checks with luacheck, interacting with `hs-minor-mode' and |
| 45 | ;; online documentation lookup. | ||
| 45 | 46 | ||
| 46 | ;; The following variables are available for customization (see more via | 47 | ;; The following variables are available for customization (see more via |
| 47 | ;; `M-x customize-group lua`): | 48 | ;; `M-x customize-group lua`): |
| @@ -85,6 +86,10 @@ | |||
| 85 | ;; - Cmd `lua-send-region': send active region | 86 | ;; - Cmd `lua-send-region': send active region |
| 86 | ;; - Cmd `lua-restart-with-whole-file': restart REPL and send whole buffer | 87 | ;; - Cmd `lua-restart-with-whole-file': restart REPL and send whole buffer |
| 87 | 88 | ||
| 89 | ;; To enable on-the-fly linting, make sure you have the luacheck | ||
| 90 | ;; program installed (available from luarocks) and activate | ||
| 91 | ;; `flymake-mode'. | ||
| 92 | |||
| 88 | ;; See "M-x apropos-command ^lua-" for a list of commands. | 93 | ;; See "M-x apropos-command ^lua-" for a list of commands. |
| 89 | ;; See "M-x customize-group lua" for a list of customizable variables. | 94 | ;; See "M-x customize-group lua" for a list of customizable variables. |
| 90 | 95 | ||
| @@ -710,7 +715,7 @@ index of respective Lua reference manuals.") | |||
| 710 | ;; via `lua-mode-map'. | 715 | ;; via `lua-mode-map'. |
| 711 | (setq-local electric-indent-chars | 716 | (setq-local electric-indent-chars |
| 712 | (append electric-indent-chars lua--electric-indent-chars))) | 717 | (append electric-indent-chars lua--electric-indent-chars))) |
| 713 | 718 | (add-hook 'flymake-diagnostic-functions #'lua-flymake nil t) | |
| 714 | 719 | ||
| 715 | ;; setup menu bar entry (XEmacs style) | 720 | ;; setup menu bar entry (XEmacs style) |
| 716 | (if (and (featurep 'menubar) | 721 | (if (and (featurep 'menubar) |
| @@ -2194,6 +2199,58 @@ left out." | |||
| 2194 | (forward-sexp 1)) | 2199 | (forward-sexp 1)) |
| 2195 | (setq count (1- count)))))) | 2200 | (setq count (1- count)))))) |
| 2196 | 2201 | ||
| 2202 | ;; Flymake integration | ||
| 2203 | |||
| 2204 | (defcustom lua-luacheck-program "luacheck" | ||
| 2205 | "Name of the luacheck executable." | ||
| 2206 | :type 'string | ||
| 2207 | :group 'lua) | ||
| 2208 | |||
| 2209 | (defvar-local lua--flymake-process nil) | ||
| 2210 | |||
| 2211 | (defun lua-flymake (report-fn &rest _args) | ||
| 2212 | "Flymake backend using the luacheck program. | ||
| 2213 | Takes a Flymake callback REPORT-FN as argument, as expected of a | ||
| 2214 | member of `flymake-diagnostic-functions'." | ||
| 2215 | (when (process-live-p lua--flymake-process) | ||
| 2216 | (kill-process lua--flymake-process)) | ||
| 2217 | (let ((source (current-buffer))) | ||
| 2218 | (save-restriction | ||
| 2219 | (widen) | ||
| 2220 | (setq lua--flymake-process | ||
| 2221 | (make-process | ||
| 2222 | :name "luacheck" :noquery t :connection-type 'pipe | ||
| 2223 | :buffer (generate-new-buffer " *flymake-luacheck*") | ||
| 2224 | :command `(,lua-luacheck-program | ||
| 2225 | "--codes" "--ranges" "--formatter" "plain" "-") | ||
| 2226 | :sentinel | ||
| 2227 | (lambda (proc _event) | ||
| 2228 | (when (eq 'exit (process-status proc)) | ||
| 2229 | (unwind-protect | ||
| 2230 | (if (with-current-buffer source | ||
| 2231 | (eq proc lua--flymake-process)) | ||
| 2232 | (with-current-buffer (process-buffer proc) | ||
| 2233 | (goto-char (point-min)) | ||
| 2234 | (cl-loop | ||
| 2235 | while (search-forward-regexp | ||
| 2236 | "^\\([^:]*\\):\\([0-9]+\\):\\([0-9]+\\)-\\([0-9]+\\): \\(.*\\)$" | ||
| 2237 | nil t) | ||
| 2238 | for line = (string-to-number (match-string 2)) | ||
| 2239 | for col1 = (string-to-number (match-string 3)) | ||
| 2240 | for col2 = (1+ (string-to-number (match-string 4))) | ||
| 2241 | for msg = (match-string 5) | ||
| 2242 | for type = (if (string-match-p "\\`(E" msg) :error :warning) | ||
| 2243 | collect (flymake-make-diagnostic source | ||
| 2244 | (cons line col1) | ||
| 2245 | (cons line col2) | ||
| 2246 | type | ||
| 2247 | msg) | ||
| 2248 | into diags | ||
| 2249 | finally (funcall report-fn diags))) | ||
| 2250 | (flymake-log :warning "Canceling obsolete check %s" proc)) | ||
| 2251 | (kill-buffer (process-buffer proc))))))) | ||
| 2252 | (process-send-region lua--flymake-process (point-min) (point-max)) | ||
| 2253 | (process-send-eof lua--flymake-process)))) | ||
| 2197 | 2254 | ||
| 2198 | ;; menu bar | 2255 | ;; menu bar |
| 2199 | 2256 | ||
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 4e59afa..63a86ad 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el | |||
| @@ -275,7 +275,7 @@ cause lag when typing on slower machines." | |||
| 275 | 275 | ||
| 276 | (defcustom markdown-uri-types | 276 | (defcustom markdown-uri-types |
| 277 | '("acap" "cid" "data" "dav" "fax" "file" "ftp" | 277 | '("acap" "cid" "data" "dav" "fax" "file" "ftp" |
| 278 | "gopher" "http" "https" "imap" "ldap" "mailto" | 278 | "geo" "gopher" "http" "https" "imap" "ldap" "mailto" |
| 279 | "mid" "message" "modem" "news" "nfs" "nntp" | 279 | "mid" "message" "modem" "news" "nfs" "nntp" |
| 280 | "pop" "prospero" "rtsp" "service" "sip" "tel" | 280 | "pop" "prospero" "rtsp" "service" "sip" "tel" |
| 281 | "telnet" "tip" "urn" "vemmi" "wais") | 281 | "telnet" "tip" "urn" "vemmi" "wais") |
| @@ -880,8 +880,9 @@ Group 6 matches the closing square brackets.") | |||
| 880 | (concat "\\(" (regexp-opt markdown-uri-types) ":[^]\t\n\r<>; ]+\\)") | 880 | (concat "\\(" (regexp-opt markdown-uri-types) ":[^]\t\n\r<>; ]+\\)") |
| 881 | "Regular expression for matching inline URIs.") | 881 | "Regular expression for matching inline URIs.") |
| 882 | 882 | ||
| 883 | ;; CommanMark specification says scheme length is 2-32 characters | ||
| 883 | (defconst markdown-regex-angle-uri | 884 | (defconst markdown-regex-angle-uri |
| 884 | (concat "\\(<\\)\\(" (regexp-opt markdown-uri-types) ":[^]\t\n\r<>,;()]+\\)\\(>\\)") | 885 | (concat "\\(<\\)\\([a-z][a-z0-9.+-]\\{1,31\\}:[^]\t\n\r<>,;()]+\\)\\(>\\)") |
| 885 | "Regular expression for matching inline URIs in angle brackets.") | 886 | "Regular expression for matching inline URIs in angle brackets.") |
| 886 | 887 | ||
| 887 | (defconst markdown-regex-email | 888 | (defconst markdown-regex-email |
| @@ -6408,7 +6409,7 @@ following section." | |||
| 6408 | (while (and (not found) | 6409 | (while (and (not found) |
| 6409 | (not (bobp)) | 6410 | (not (bobp)) |
| 6410 | (re-search-backward markdown-regex-header nil 'move)) | 6411 | (re-search-backward markdown-regex-header nil 'move)) |
| 6411 | (when (not (markdown-code-block-at-pos (match-beginning 0)))) | 6412 | (markdown-code-block-at-pos (match-beginning 0)) |
| 6412 | (setq found (match-beginning 0))) | 6413 | (setq found (match-beginning 0))) |
| 6413 | (setq arg (1- arg))) | 6414 | (setq arg (1- arg))) |
| 6414 | ;; Move forward with negative argument. | 6415 | ;; Move forward with negative argument. |
| @@ -6417,7 +6418,7 @@ following section." | |||
| 6417 | (while (and (not found) | 6418 | (while (and (not found) |
| 6418 | (not (eobp)) | 6419 | (not (eobp)) |
| 6419 | (re-search-forward markdown-regex-header nil 'move)) | 6420 | (re-search-forward markdown-regex-header nil 'move)) |
| 6420 | (when (not (markdown-code-block-at-pos (match-beginning 0)))) | 6421 | (markdown-code-block-at-pos (match-beginning 0)) |
| 6421 | (setq found (match-beginning 0))) | 6422 | (setq found (match-beginning 0))) |
| 6422 | (setq arg (1+ arg))) | 6423 | (setq arg (1+ arg))) |
| 6423 | (when found | 6424 | (when found |
| @@ -7541,8 +7542,17 @@ This is the inverse of `markdown-live-preview-buffer'.") | |||
| 7541 | (defun markdown-live-preview-window-eww (file) | 7542 | (defun markdown-live-preview-window-eww (file) |
| 7542 | "Preview FILE with eww. | 7543 | "Preview FILE with eww. |
| 7543 | To be used with `markdown-live-preview-window-function'." | 7544 | To be used with `markdown-live-preview-window-function'." |
| 7545 | (when (and (bound-and-true-p eww-auto-rename-buffer) | ||
| 7546 | markdown-live-preview-buffer) | ||
| 7547 | (kill-buffer markdown-live-preview-buffer)) | ||
| 7544 | (eww-open-file file) | 7548 | (eww-open-file file) |
| 7545 | (get-buffer "*eww*")) | 7549 | ;; #737 if `eww-auto-rename-buffer' is non-nil, the buffer name is not "*eww*" |
| 7550 | ;; Try to find the buffer whose name ends with "eww*" | ||
| 7551 | (if (bound-and-true-p eww-auto-rename-buffer) | ||
| 7552 | (cl-loop for buf in (buffer-list) | ||
| 7553 | when (string-match-p "eww\\*\\'" (buffer-name buf)) | ||
| 7554 | return buf) | ||
| 7555 | (get-buffer "*eww*"))) | ||
| 7546 | 7556 | ||
| 7547 | (defun markdown-visual-lines-between-points (beg end) | 7557 | (defun markdown-visual-lines-between-points (beg end) |
| 7548 | (save-excursion | 7558 | (save-excursion |
| @@ -8596,7 +8606,8 @@ This can be toggled with `markdown-toggle-inline-images' | |||
| 8596 | or \\[markdown-toggle-inline-images]." | 8606 | or \\[markdown-toggle-inline-images]." |
| 8597 | (interactive) | 8607 | (interactive) |
| 8598 | (mapc #'delete-overlay markdown-inline-image-overlays) | 8608 | (mapc #'delete-overlay markdown-inline-image-overlays) |
| 8599 | (setq markdown-inline-image-overlays nil)) | 8609 | (setq markdown-inline-image-overlays nil) |
| 8610 | (when (fboundp 'clear-image-cache) (clear-image-cache))) | ||
| 8600 | 8611 | ||
| 8601 | (defcustom markdown-display-remote-images nil | 8612 | (defcustom markdown-display-remote-images nil |
| 8602 | "If non-nil, download and display remote images. | 8613 | "If non-nil, download and display remote images. |
| @@ -8745,10 +8756,16 @@ mode to use is `tuareg-mode'." | |||
| 8745 | LANG is a string, and the returned major mode is a symbol." | 8756 | LANG is a string, and the returned major mode is a symbol." |
| 8746 | (cl-find-if | 8757 | (cl-find-if |
| 8747 | 'fboundp | 8758 | 'fboundp |
| 8748 | (list (cdr (assoc lang markdown-code-lang-modes)) | 8759 | (nconc (list (cdr (assoc lang markdown-code-lang-modes)) |
| 8749 | (cdr (assoc (downcase lang) markdown-code-lang-modes)) | 8760 | (cdr (assoc (downcase lang) markdown-code-lang-modes))) |
| 8750 | (intern (concat lang "-mode")) | 8761 | (and (fboundp 'treesit-language-available-p) |
| 8751 | (intern (concat (downcase lang) "-mode"))))) | 8762 | (list (and (treesit-language-available-p (intern lang)) |
| 8763 | (intern (concat lang "-ts-mode"))) | ||
| 8764 | (and (treesit-language-available-p (intern (downcase lang))) | ||
| 8765 | (intern (concat (downcase lang) "-ts-mode"))))) | ||
| 8766 | (list | ||
| 8767 | (intern (concat lang "-mode")) | ||
| 8768 | (intern (concat (downcase lang) "-mode")))))) | ||
| 8752 | 8769 | ||
| 8753 | (defun markdown-fontify-code-blocks-generic (matcher last) | 8770 | (defun markdown-fontify-code-blocks-generic (matcher last) |
| 8754 | "Add text properties to next code block from point to LAST. | 8771 | "Add text properties to next code block from point to LAST. |
| @@ -9186,6 +9203,11 @@ This function assumes point is on a table." | |||
| 9186 | (push (buffer-substring-no-properties cur (point-max)) ret)) | 9203 | (push (buffer-substring-no-properties cur (point-max)) ret)) |
| 9187 | (nreverse ret)))) | 9204 | (nreverse ret)))) |
| 9188 | 9205 | ||
| 9206 | (defsubst markdown--is-delimiter-row (line) | ||
| 9207 | (and (string-match-p "\\`[ \t]*|[ \t]*[-:]" line) | ||
| 9208 | (cl-loop for c across line | ||
| 9209 | always (member c '(?| ?- ?: ?\t ? ))))) | ||
| 9210 | |||
| 9189 | (defun markdown-table-align () | 9211 | (defun markdown-table-align () |
| 9190 | "Align table at point. | 9212 | "Align table at point. |
| 9191 | This function assumes point is on a table." | 9213 | This function assumes point is on a table." |
| @@ -9198,9 +9220,10 @@ This function assumes point is on a table." | |||
| 9198 | ;; Store table indent | 9220 | ;; Store table indent |
| 9199 | (indent (progn (looking-at "[ \t]*") (match-string 0))) | 9221 | (indent (progn (looking-at "[ \t]*") (match-string 0))) |
| 9200 | ;; Split table in lines and save column format specifier | 9222 | ;; Split table in lines and save column format specifier |
| 9201 | (lines (mapcar (lambda (l) | 9223 | (lines (mapcar (lambda (line) |
| 9202 | (if (string-match-p "\\`[ \t]*|[ \t]*[-:]" l) | 9224 | (if (markdown--is-delimiter-row line) |
| 9203 | (progn (setq fmtspec (or fmtspec l)) nil) l)) | 9225 | (progn (setq fmtspec (or fmtspec line)) nil) |
| 9226 | line)) | ||
| 9204 | (markdown--split-string (buffer-substring begin end) "\n"))) | 9227 | (markdown--split-string (buffer-substring begin end) "\n"))) |
| 9205 | ;; Split lines in cells | 9228 | ;; Split lines in cells |
| 9206 | (cells (mapcar (lambda (l) (markdown--table-line-to-columns l)) | 9229 | (cells (mapcar (lambda (l) (markdown--table-line-to-columns l)) |
diff --git a/.emacs.d/snippets/python-mode.statnett/format b/.emacs.d/snippets/python-mode.statnett/format deleted file mode 100644 index 85c2d6f..0000000 --- a/.emacs.d/snippets/python-mode.statnett/format +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | # -*- mode: snippet -*- | ||
| 2 | # name: format | ||
| 3 | # key: sf | ||
| 4 | # group: object oriented | ||
| 5 | # -- | ||
| 6 | .format($0) \ No newline at end of file | ||
diff --git a/.emacs.d/snippets/python-mode.statnett/printf b/.emacs.d/snippets/python-mode.statnett/printf index c69d6da..229bdd9 100644 --- a/.emacs.d/snippets/python-mode.statnett/printf +++ b/.emacs.d/snippets/python-mode.statnett/printf | |||
| @@ -2,4 +2,4 @@ | |||
| 2 | # name: printf | 2 | # name: printf |
| 3 | # key: pf | 3 | # key: pf |
| 4 | # -- | 4 | # -- |
| 5 | print("$0{}".format()) \ No newline at end of file | 5 | print(f"$0") \ No newline at end of file |
diff --git a/.emacs.d/snippets/python-mode/format b/.emacs.d/snippets/python-mode/format deleted file mode 100644 index 85c2d6f..0000000 --- a/.emacs.d/snippets/python-mode/format +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | # -*- mode: snippet -*- | ||
| 2 | # name: format | ||
| 3 | # key: sf | ||
| 4 | # group: object oriented | ||
| 5 | # -- | ||
| 6 | .format($0) \ No newline at end of file | ||
diff --git a/.emacs.d/snippets/python-mode/printf b/.emacs.d/snippets/python-mode/printf index 78c67a8..087b2eb 100644 --- a/.emacs.d/snippets/python-mode/printf +++ b/.emacs.d/snippets/python-mode/printf | |||
| @@ -2,4 +2,4 @@ | |||
| 2 | # name: printf | 2 | # name: printf |
| 3 | # key: pf | 3 | # key: pf |
| 4 | # -- | 4 | # -- |
| 5 | print('$0{}'.format()) \ No newline at end of file | 5 | print(f'$0') \ No newline at end of file |
