summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/markdown-mode.el
diff options
context:
space:
mode:
authorSimeon Simeonov2023-03-02 22:22:16 +0100
committerSimeon Simeonov2023-03-02 22:22:16 +0100
commitb7b77a527e4920389667b1ac90c447f52db70996 (patch)
tree378fe0644581d0ad23df35146cf2f005e9b2087b /.emacs.d/lisp/markdown-mode.el
parent831b5da37edd9b846c56937ca873975c3f0f0294 (diff)
Upgrade .emacs.d/lisp/lua-mode.el and .emacs.d/lisp/markdown-mode.el. Modify .emacs.d/snippets/python-mode/printf
Diffstat (limited to '.emacs.d/lisp/markdown-mode.el')
-rw-r--r--.emacs.d/lisp/markdown-mode.el49
1 files changed, 36 insertions, 13 deletions
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.
7543To be used with `markdown-live-preview-window-function'." 7544To 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'
8596or \\[markdown-toggle-inline-images]." 8606or \\[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'."
8745LANG is a string, and the returned major mode is a symbol." 8756LANG 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.
9191This function assumes point is on a table." 9213This 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))