diff options
| author | Simeon Simeonov | 2021-06-19 23:11:32 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2021-06-19 23:11:32 +0200 |
| commit | f5006c71f40842314efab7149916ca08058cfa77 (patch) | |
| tree | 4152803b2266c5c80ca7311ecf18ffe41124d72c | |
| parent | b57f8663d4bd5ee03c55df2f7e0372630b72bab7 (diff) | |
Update markdown-mode
| -rw-r--r-- | .emacs.d/lisp/markdown-mode.el | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index aba9e6f..502eb26 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el | |||
| @@ -765,8 +765,8 @@ Group 5 matches the closing brace (optional), whitespace, and newline. | |||
| 765 | Groups need to agree with `markdown-regex-tilde-fence-begin'.") | 765 | Groups need to agree with `markdown-regex-tilde-fence-begin'.") |
| 766 | 766 | ||
| 767 | (defconst markdown-regex-gfm-code-block-close | 767 | (defconst markdown-regex-gfm-code-block-close |
| 768 | "^[[:blank:]]*\\(?1:```\\)\\(?2:\\s *?\\)$" | 768 | "^[[:blank:]]*\\(?1:```\\)\\(?2:\\s *?\\)$" |
| 769 | "Regular expression matching closing of GFM code blocks. | 769 | "Regular expression matching closing of GFM code blocks. |
| 770 | Group 1 matches the closing three backquotes. | 770 | Group 1 matches the closing three backquotes. |
| 771 | Group 2 matches any whitespace and the final newline.") | 771 | Group 2 matches any whitespace and the final newline.") |
| 772 | 772 | ||
| @@ -1210,9 +1210,9 @@ giving the bounds of the current and parent list items." | |||
| 1210 | (marker (cl-fifth cur-bounds))) | 1210 | (marker (cl-fifth cur-bounds))) |
| 1211 | (setq bounds (markdown--append-list-item-bounds | 1211 | (setq bounds (markdown--append-list-item-bounds |
| 1212 | marker indent cur-bounds bounds)) | 1212 | marker indent cur-bounds bounds)) |
| 1213 | (when (and (<= start (point)) (<= (point) end)) | 1213 | (when (and (<= start (point)) (<= (point) end)) |
| 1214 | (setq prev-list-line (line-number-at-pos first)) | 1214 | (setq prev-list-line (line-number-at-pos first)) |
| 1215 | (put-text-property first last 'markdown-list-item bounds))))) | 1215 | (put-text-property first last 'markdown-list-item bounds))))) |
| 1216 | (end-of-line))))) | 1216 | (end-of-line))))) |
| 1217 | 1217 | ||
| 1218 | (defun markdown-syntax-propertize-pre-blocks (start end) | 1218 | (defun markdown-syntax-propertize-pre-blocks (start end) |
| @@ -2079,8 +2079,8 @@ Depending on your font, some reasonable choices are: | |||
| 2079 | (markdown-match-pre-blocks . ((0 'markdown-pre-face))) | 2079 | (markdown-match-pre-blocks . ((0 'markdown-pre-face))) |
| 2080 | (markdown-fontify-headings) | 2080 | (markdown-fontify-headings) |
| 2081 | (markdown-match-declarative-metadata . ((1 'markdown-metadata-key-face) | 2081 | (markdown-match-declarative-metadata . ((1 'markdown-metadata-key-face) |
| 2082 | (2 'markdown-markup-face) | 2082 | (2 'markdown-markup-face) |
| 2083 | (3 'markdown-metadata-value-face))) | 2083 | (3 'markdown-metadata-value-face))) |
| 2084 | (markdown-match-pandoc-metadata . ((1 'markdown-markup-face) | 2084 | (markdown-match-pandoc-metadata . ((1 'markdown-markup-face) |
| 2085 | (2 'markdown-markup-face) | 2085 | (2 'markdown-markup-face) |
| 2086 | (3 'markdown-metadata-value-face))) | 2086 | (3 'markdown-metadata-value-face))) |
| @@ -2791,12 +2791,12 @@ When FACELESS is non-nil, do not return matches where faces have been applied." | |||
| 2791 | (not (markdown-in-comment-p (match-end 1))) | 2791 | (not (markdown-in-comment-p (match-end 1))) |
| 2792 | (not (markdown-code-block-at-pos (match-beginning 1))))) | 2792 | (not (markdown-code-block-at-pos (match-beginning 1))))) |
| 2793 | markdown-regex-code last t) | 2793 | markdown-regex-code last t) |
| 2794 | (set-match-data (list (match-beginning 1) (match-end 1) | 2794 | (set-match-data (list (match-beginning 1) (match-end 1) |
| 2795 | (match-beginning 2) (match-end 2) | 2795 | (match-beginning 2) (match-end 2) |
| 2796 | (match-beginning 3) (match-end 3) | 2796 | (match-beginning 3) (match-end 3) |
| 2797 | (match-beginning 4) (match-end 4))) | 2797 | (match-beginning 4) (match-end 4))) |
| 2798 | (goto-char (min (1+ (match-end 0)) last (point-max))) | 2798 | (goto-char (min (1+ (match-end 0)) last (point-max))) |
| 2799 | t)) | 2799 | t)) |
| 2800 | 2800 | ||
| 2801 | (defun markdown--gfm-markup-underscore-p (begin end) | 2801 | (defun markdown--gfm-markup-underscore-p (begin end) |
| 2802 | (let ((is-underscore (eql (char-after begin) ?_))) | 2802 | (let ((is-underscore (eql (char-after begin) ?_))) |
| @@ -3051,9 +3051,9 @@ processed elements." | |||
| 3051 | ;; Move over balanced expressions to closing right bracket. | 3051 | ;; Move over balanced expressions to closing right bracket. |
| 3052 | ;; Catch unbalanced expression errors and return nil. | 3052 | ;; Catch unbalanced expression errors and return nil. |
| 3053 | (first-end (condition-case nil | 3053 | (first-end (condition-case nil |
| 3054 | (and (goto-char first-begin) | 3054 | (and (goto-char first-begin) |
| 3055 | (scan-sexps (point) 1)) | 3055 | (scan-sexps (point) 1)) |
| 3056 | (error nil))) | 3056 | (error nil))) |
| 3057 | ;; Continue with point at CONT-POINT upon failure. | 3057 | ;; Continue with point at CONT-POINT upon failure. |
| 3058 | (cont-point (min (1+ first-begin) last)) | 3058 | (cont-point (min (1+ first-begin) last)) |
| 3059 | second-begin second-end url-begin url-end | 3059 | second-begin second-end url-begin url-end |
| @@ -3064,8 +3064,8 @@ processed elements." | |||
| 3064 | ;; Scan across balanced expressions for closing parenthesis/bracket. | 3064 | ;; Scan across balanced expressions for closing parenthesis/bracket. |
| 3065 | (setq second-begin (point) | 3065 | (setq second-begin (point) |
| 3066 | second-end (condition-case nil | 3066 | second-end (condition-case nil |
| 3067 | (scan-sexps (point) 1) | 3067 | (scan-sexps (point) 1) |
| 3068 | (error nil))) | 3068 | (error nil))) |
| 3069 | ;; Check that closing parenthesis/bracket is in range. | 3069 | ;; Check that closing parenthesis/bracket is in range. |
| 3070 | (if (and second-end (<= second-end end-of-block) (<= second-end last)) | 3070 | (if (and second-end (<= second-end end-of-block) (<= second-end last)) |
| 3071 | (progn | 3071 | (progn |
| @@ -3316,7 +3316,7 @@ SEQ may be an atom or a sequence." | |||
| 3316 | (let ((margin-left-space-count | 3316 | (let ((margin-left-space-count |
| 3317 | (- markdown-marginalize-headers-margin-width level))) | 3317 | (- markdown-marginalize-headers-margin-width level))) |
| 3318 | (concat (make-string margin-left-space-count ? ) | 3318 | (concat (make-string margin-left-space-count ? ) |
| 3319 | (make-string level ?#)))) | 3319 | (make-string level ?#)))) |
| 3320 | 3320 | ||
| 3321 | (defun markdown-marginalize-update-current () | 3321 | (defun markdown-marginalize-update-current () |
| 3322 | "Update the window configuration to create a left margin." | 3322 | "Update the window configuration to create a left margin." |
| @@ -3426,7 +3426,7 @@ SEQ may be an atom or a sequence." | |||
| 3426 | font-lock-multiline t | 3426 | font-lock-multiline t |
| 3427 | ,@(when (and markdown-hide-markup hr-char) | 3427 | ,@(when (and markdown-hide-markup hr-char) |
| 3428 | `(display ,(make-string | 3428 | `(display ,(make-string |
| 3429 | (window-body-width) hr-char))))) | 3429 | (1- (window-body-width)) hr-char))))) |
| 3430 | t))) | 3430 | t))) |
| 3431 | 3431 | ||
| 3432 | (defun markdown-fontify-sub-superscripts (last) | 3432 | (defun markdown-fontify-sub-superscripts (last) |
| @@ -4329,7 +4329,7 @@ if three backquotes inserted at the beginning of line." | |||
| 4329 | (defun markdown-gfm-add-used-language (lang) | 4329 | (defun markdown-gfm-add-used-language (lang) |
| 4330 | "Clean LANG and add to list of used languages." | 4330 | "Clean LANG and add to list of used languages." |
| 4331 | (setq markdown-gfm-used-languages | 4331 | (setq markdown-gfm-used-languages |
| 4332 | (cons lang (remove lang markdown-gfm-used-languages)))) | 4332 | (cons lang (remove lang markdown-gfm-used-languages)))) |
| 4333 | 4333 | ||
| 4334 | (defcustom markdown-spaces-after-code-fence 1 | 4334 | (defcustom markdown-spaces-after-code-fence 1 |
| 4335 | "Number of space characters to insert after a code fence. | 4335 | "Number of space characters to insert after a code fence. |
| @@ -5757,7 +5757,7 @@ the link, and line is the line number on which the link appears." | |||
| 5757 | (let* ((text (match-string-no-properties 3)) | 5757 | (let* ((text (match-string-no-properties 3)) |
| 5758 | (reference (match-string-no-properties 6)) | 5758 | (reference (match-string-no-properties 6)) |
| 5759 | (target (downcase (if (string= reference "") text reference)))) | 5759 | (target (downcase (if (string= reference "") text reference)))) |
| 5760 | (,f text target result)))) | 5760 | (,f text target result)))) |
| 5761 | (reverse result))) | 5761 | (reverse result))) |
| 5762 | 5762 | ||
| 5763 | (defmacro markdown-collect-always (_ target result) | 5763 | (defmacro markdown-collect-always (_ target result) |
| @@ -6397,9 +6397,9 @@ means move forward N blocks." | |||
| 6397 | (beginning-of-line) | 6397 | (beginning-of-line) |
| 6398 | ;; Skip over code block endings. | 6398 | ;; Skip over code block endings. |
| 6399 | (when (markdown-range-properties-exist | 6399 | (when (markdown-range-properties-exist |
| 6400 | (point-at-bol) (point-at-eol) | 6400 | (point-at-bol) (point-at-eol) |
| 6401 | '(markdown-gfm-block-end | 6401 | '(markdown-gfm-block-end |
| 6402 | markdown-tilde-fence-end)) | 6402 | markdown-tilde-fence-end)) |
| 6403 | (forward-line -1)) | 6403 | (forward-line -1)) |
| 6404 | ;; Skip over blank lines inside blockquotes. | 6404 | ;; Skip over blank lines inside blockquotes. |
| 6405 | (while (and (not (eobp)) | 6405 | (while (and (not (eobp)) |
| @@ -6430,9 +6430,9 @@ means move forward N blocks." | |||
| 6430 | '(markdown-gfm-block-end | 6430 | '(markdown-gfm-block-end |
| 6431 | markdown-tilde-fence-end)))) | 6431 | markdown-tilde-fence-end)))) |
| 6432 | (setq skip (markdown-range-properties-exist | 6432 | (setq skip (markdown-range-properties-exist |
| 6433 | (point-at-bol) (point-at-eol) | 6433 | (point-at-bol) (point-at-eol) |
| 6434 | '(markdown-gfm-block-begin | 6434 | '(markdown-gfm-block-begin |
| 6435 | markdown-tilde-fence-begin))) | 6435 | markdown-tilde-fence-begin))) |
| 6436 | (forward-line -1)) | 6436 | (forward-line -1)) |
| 6437 | (unless (bobp) | 6437 | (unless (bobp) |
| 6438 | (forward-line 1)))))))) | 6438 | (forward-line 1)))))))) |
| @@ -7130,9 +7130,9 @@ This puts point at the start of the current subtree, and mark at the end." | |||
| 7130 | (narrow-to-region | 7130 | (narrow-to-region |
| 7131 | (progn (markdown-back-to-heading-over-code-block t) (point)) | 7131 | (progn (markdown-back-to-heading-over-code-block t) (point)) |
| 7132 | (progn (markdown-end-of-subtree) | 7132 | (progn (markdown-end-of-subtree) |
| 7133 | (if (and (markdown-heading-at-point) (not (eobp))) | 7133 | (if (and (markdown-heading-at-point) (not (eobp))) |
| 7134 | (backward-char 1)) | 7134 | (backward-char 1)) |
| 7135 | (point)))))) | 7135 | (point)))))) |
| 7136 | 7136 | ||
| 7137 | 7137 | ||
| 7138 | ;;; Generic Structure Editing, Completion, and Cycling Commands =============== | 7138 | ;;; Generic Structure Editing, Completion, and Cycling Commands =============== |
| @@ -7591,7 +7591,7 @@ displaying the rendered output." | |||
| 7591 | output buffer in another window." | 7591 | output buffer in another window." |
| 7592 | (if markdown-live-preview-mode | 7592 | (if markdown-live-preview-mode |
| 7593 | (markdown-display-buffer-other-window (markdown-live-preview-export))) | 7593 | (markdown-display-buffer-other-window (markdown-live-preview-export))) |
| 7594 | (markdown-live-preview-mode)) | 7594 | (markdown-live-preview-mode)) |
| 7595 | 7595 | ||
| 7596 | (defun markdown-live-preview-re-export () | 7596 | (defun markdown-live-preview-re-export () |
| 7597 | "Re export source buffer." | 7597 | "Re export source buffer." |
| @@ -8087,7 +8087,7 @@ newline after." | |||
| 8087 | (set-buffer-modified-p nil))))) | 8087 | (set-buffer-modified-p nil))))) |
| 8088 | 8088 | ||
| 8089 | (defun markdown-check-change-for-wiki-link-after-change (from to _) | 8089 | (defun markdown-check-change-for-wiki-link-after-change (from to _) |
| 8090 | "Check region between FROM and TO for wiki links and re-fontify as needed. | 8090 | "Check region between FROM and TO for wiki links and re-fontify as needed. |
| 8091 | Designed to be used with the `after-change-functions' hook." | 8091 | Designed to be used with the `after-change-functions' hook." |
| 8092 | (markdown-check-change-for-wiki-link from to)) | 8092 | (markdown-check-change-for-wiki-link from to)) |
| 8093 | 8093 | ||
| @@ -8131,7 +8131,7 @@ These are only enabled when `markdown-wiki-link-fontify-missing' is non-nil." | |||
| 8131 | (markdown-fontify-buffer-wiki-links)) | 8131 | (markdown-fontify-buffer-wiki-links)) |
| 8132 | (remove-hook 'window-configuration-change-hook | 8132 | (remove-hook 'window-configuration-change-hook |
| 8133 | 'markdown-fontify-buffer-wiki-links t) | 8133 | 'markdown-fontify-buffer-wiki-links t) |
| 8134 | (markdown-unfontify-region-wiki-links (point-min) (point-max)))) | 8134 | (markdown-unfontify-region-wiki-links (point-min) (point-max)))) |
| 8135 | 8135 | ||
| 8136 | 8136 | ||
| 8137 | ;;; Following & Doing ========================================================= | 8137 | ;;; Following & Doing ========================================================= |
| @@ -8390,41 +8390,41 @@ is found, the return value is the same value returned by | |||
| 8390 | Returns t if added. | 8390 | Returns t if added. |
| 8391 | Returns nil if non-applicable." | 8391 | Returns nil if non-applicable." |
| 8392 | (interactive) | 8392 | (interactive) |
| 8393 | (let ((bounds (markdown-cur-list-item-bounds))) | 8393 | (let ((bounds (markdown-cur-list-item-bounds))) |
| 8394 | (if bounds | 8394 | (if bounds |
| 8395 | (unless (cl-sixth bounds) | 8395 | (unless (cl-sixth bounds) |
| 8396 | (let ((pos (+ (cl-first bounds) (cl-fourth bounds))) | 8396 | (let ((pos (+ (cl-first bounds) (cl-fourth bounds))) |
| 8397 | (markup "[ ] ")) | 8397 | (markup "[ ] ")) |
| 8398 | (if (< pos (point)) | ||
| 8399 | (save-excursion | ||
| 8400 | (goto-char pos) | ||
| 8401 | (insert markup)) | ||
| 8402 | (goto-char pos) | ||
| 8403 | (insert markup)) | ||
| 8404 | (syntax-propertize (+ (cl-second bounds) 4)) | ||
| 8405 | t)) | ||
| 8406 | (unless (save-excursion | ||
| 8407 | (back-to-indentation) | ||
| 8408 | (or (markdown-list-item-at-point-p) | ||
| 8409 | (markdown-heading-at-point) | ||
| 8410 | (markdown-in-comment-p) | ||
| 8411 | (markdown-code-block-at-point-p))) | ||
| 8412 | (let ((pos (save-excursion | ||
| 8413 | (back-to-indentation) | ||
| 8414 | (point))) | ||
| 8415 | (markup (concat (or (save-excursion | ||
| 8416 | (beginning-of-line 0) | ||
| 8417 | (cl-fifth (markdown-cur-list-item-bounds))) | ||
| 8418 | markdown-unordered-list-item-prefix) | ||
| 8419 | "[ ] "))) | ||
| 8420 | (if (< pos (point)) | 8398 | (if (< pos (point)) |
| 8421 | (save-excursion | 8399 | (save-excursion |
| 8422 | (goto-char pos) | 8400 | (goto-char pos) |
| 8423 | (insert markup)) | 8401 | (insert markup)) |
| 8424 | (goto-char pos) | 8402 | (goto-char pos) |
| 8425 | (insert markup)) | 8403 | (insert markup)) |
| 8426 | (syntax-propertize (point-at-eol)) | 8404 | (syntax-propertize (+ (cl-second bounds) 4)) |
| 8427 | t))))) | 8405 | t)) |
| 8406 | (unless (save-excursion | ||
| 8407 | (back-to-indentation) | ||
| 8408 | (or (markdown-list-item-at-point-p) | ||
| 8409 | (markdown-heading-at-point) | ||
| 8410 | (markdown-in-comment-p) | ||
| 8411 | (markdown-code-block-at-point-p))) | ||
| 8412 | (let ((pos (save-excursion | ||
| 8413 | (back-to-indentation) | ||
| 8414 | (point))) | ||
| 8415 | (markup (concat (or (save-excursion | ||
| 8416 | (beginning-of-line 0) | ||
| 8417 | (cl-fifth (markdown-cur-list-item-bounds))) | ||
| 8418 | markdown-unordered-list-item-prefix) | ||
| 8419 | "[ ] "))) | ||
| 8420 | (if (< pos (point)) | ||
| 8421 | (save-excursion | ||
| 8422 | (goto-char pos) | ||
| 8423 | (insert markup)) | ||
| 8424 | (goto-char pos) | ||
| 8425 | (insert markup)) | ||
| 8426 | (syntax-propertize (point-at-eol)) | ||
| 8427 | t))))) | ||
| 8428 | 8428 | ||
| 8429 | (defun markdown-toggle-gfm-checkbox () | 8429 | (defun markdown-toggle-gfm-checkbox () |
| 8430 | "Toggle GFM checkbox at point. | 8430 | "Toggle GFM checkbox at point. |
| @@ -8536,9 +8536,9 @@ or \\[markdown-toggle-inline-images]." | |||
| 8536 | (goto-char (point-min)) | 8536 | (goto-char (point-min)) |
| 8537 | (while (re-search-forward markdown-regex-link-inline nil t) | 8537 | (while (re-search-forward markdown-regex-link-inline nil t) |
| 8538 | (let* ((start (match-beginning 0)) | 8538 | (let* ((start (match-beginning 0)) |
| 8539 | (imagep (match-beginning 1)) | 8539 | (imagep (match-beginning 1)) |
| 8540 | (end (match-end 0)) | 8540 | (end (match-end 0)) |
| 8541 | (file (match-string-no-properties 6))) | 8541 | (file (match-string-no-properties 6))) |
| 8542 | (when (and imagep | 8542 | (when (and imagep |
| 8543 | (not (zerop (length file)))) | 8543 | (not (zerop (length file)))) |
| 8544 | (unless (file-exists-p file) | 8544 | (unless (file-exists-p file) |
| @@ -8559,7 +8559,7 @@ or \\[markdown-toggle-inline-images]." | |||
| 8559 | (concat default-directory file))) | 8559 | (concat default-directory file))) |
| 8560 | (image | 8560 | (image |
| 8561 | (cond ((and markdown-max-image-size | 8561 | (cond ((and markdown-max-image-size |
| 8562 | (image-type-available-p 'imagemagick)) | 8562 | (image-type-available-p 'imagemagick)) |
| 8563 | (create-image | 8563 | (create-image |
| 8564 | abspath 'imagemagick nil | 8564 | abspath 'imagemagick nil |
| 8565 | :max-width (car markdown-max-image-size) | 8565 | :max-width (car markdown-max-image-size) |
