diff options
| author | Simeon Simeonov | 2026-07-22 11:10:34 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2026-07-22 11:10:34 +0200 |
| commit | 85601f50f236686da662b1b00e01df0a0abe761b (patch) | |
| tree | ab188e994e2bc569e0f4291c8428e13721245ebe /.emacs.d/lisp/markdown-mode.el | |
| parent | 5ae7014a54984c194f103d406f9fbdbafb277885 (diff) | |
Update markdown-mode, rust-mode and yaml-mode. Remove unused snippets
Diffstat (limited to '.emacs.d/lisp/markdown-mode.el')
| -rw-r--r-- | .emacs.d/lisp/markdown-mode.el | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 160975c..08ed4bb 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | ;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*- | 1 | ;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2007-2023 Jason R. Blevins and markdown-mode | 3 | ;; Copyright (C) 2007-2026 Jason R. Blevins and markdown-mode |
| 4 | ;; contributors (see the commit log for details). | 4 | ;; contributors (see the commit log for details). |
| 5 | 5 | ||
| 6 | ;; Author: Jason R. Blevins <jblevins@xbeta.org> | 6 | ;; Author: Jason R. Blevins <jblevins@xbeta.org> |
| 7 | ;; Maintainer: Jason R. Blevins <jblevins@xbeta.org> | 7 | ;; Maintainer: Jason R. Blevins <jblevins@xbeta.org> |
| 8 | ;; Created: May 24, 2007 | 8 | ;; Created: May 24, 2007 |
| 9 | ;; Version: 2.8-alpha | 9 | ;; Version: 2.9-alpha |
| 10 | ;; Package-Requires: ((emacs "28.1")) | 10 | ;; Package-Requires: ((emacs "28.1")) |
| 11 | ;; Keywords: Markdown, GitHub Flavored Markdown, itex | 11 | ;; Keywords: Markdown, GitHub Flavored Markdown, itex |
| 12 | ;; URL: https://jblevins.org/projects/markdown-mode/ | 12 | ;; URL: https://jblevins.org/projects/markdown-mode/ |
| @@ -2930,22 +2930,21 @@ This may be useful for tables and Pandoc's line_blocks extension." | |||
| 2930 | "Return t if PROP from BEGIN to END is equal to one of the given PROP-VALUES. | 2930 | "Return t if PROP from BEGIN to END is equal to one of the given PROP-VALUES. |
| 2931 | Also returns t if PROP is a list containing one of the PROP-VALUES. | 2931 | Also returns t if PROP is a list containing one of the PROP-VALUES. |
| 2932 | Return nil otherwise." | 2932 | Return nil otherwise." |
| 2933 | (let (props) | 2933 | (catch 'found |
| 2934 | (catch 'found | 2934 | (let ((loc begin)) |
| 2935 | (dolist (loc (number-sequence begin end)) | 2935 | (while (<= loc end) |
| 2936 | (when (setq props (get-text-property loc prop)) | 2936 | (when-let* ((props (get-text-property loc prop))) |
| 2937 | (cond ((listp props) | 2937 | (if (listp props) |
| 2938 | ;; props is a list, check for membership | 2938 | ;; props is a list, check for membership |
| 2939 | (dolist (val prop-values) | 2939 | (dolist (val prop-values) |
| 2940 | (when (memq val props) (throw 'found loc)))) | 2940 | (when (memq val props) (throw 'found loc))) |
| 2941 | (t | 2941 | (dolist (val prop-values) |
| 2942 | ;; props is a scalar, check for equality | 2942 | (when (eq val props) (throw 'found loc))))) |
| 2943 | (dolist (val prop-values) | 2943 | (setq loc (next-single-property-change loc prop nil (1+ end))))))) |
| 2944 | (when (eq val props) (throw 'found loc)))))))))) | ||
| 2945 | 2944 | ||
| 2946 | (defun markdown-range-properties-exist (begin end props) | 2945 | (defun markdown-range-properties-exist (begin end props) |
| 2947 | (cl-loop | 2946 | (cl-loop |
| 2948 | for loc in (number-sequence begin end) | 2947 | for loc from begin to end |
| 2949 | with result = nil | 2948 | with result = nil |
| 2950 | while (not | 2949 | while (not |
| 2951 | (setq result | 2950 | (setq result |
| @@ -3637,12 +3636,31 @@ SEQ may be an atom or a sequence." | |||
| 3637 | (add-text-properties fontified-start fontified-end heading-props))))) | 3636 | (add-text-properties fontified-start fontified-end heading-props))))) |
| 3638 | t)) | 3637 | t)) |
| 3639 | 3638 | ||
| 3639 | (defun markdown--fontify-table-alignment () | ||
| 3640 | "Visually align cell separators of the table line at point. | ||
| 3641 | Hiding markup makes the displayed content of a table cell | ||
| 3642 | narrower than the buffer text, which breaks the column alignment | ||
| 3643 | of tables that are aligned in the source. Give the whitespace | ||
| 3644 | before each cell separator a space display specification | ||
| 3645 | stretching it to the separator's buffer column, so that | ||
| 3646 | separators are displayed at the same column as in the source | ||
| 3647 | regardless of what is hidden before them." | ||
| 3648 | (beginning-of-line) | ||
| 3649 | (while (re-search-forward "[ \t]+|" (line-end-position) t) | ||
| 3650 | (let ((separator (1- (match-end 0)))) | ||
| 3651 | (unless (markdown-inline-code-at-pos-p separator) | ||
| 3652 | (put-text-property | ||
| 3653 | (match-beginning 0) separator | ||
| 3654 | 'display `(space :align-to ,(1- (current-column)))))))) | ||
| 3655 | |||
| 3640 | (defun markdown-fontify-tables (last) | 3656 | (defun markdown-fontify-tables (last) |
| 3641 | (when (re-search-forward "|" last t) | 3657 | (when (re-search-forward "|" last t) |
| 3642 | (when (markdown-table-at-point-p) | 3658 | (when (markdown-table-at-point-p) |
| 3643 | (font-lock-append-text-property | 3659 | (font-lock-append-text-property |
| 3644 | (line-beginning-position) (min (1+ (line-end-position)) (point-max)) | 3660 | (line-beginning-position) (min (1+ (line-end-position)) (point-max)) |
| 3645 | 'face 'markdown-table-face)) | 3661 | 'face 'markdown-table-face) |
| 3662 | (when (or markdown-hide-markup markdown-hide-urls) | ||
| 3663 | (markdown--fontify-table-alignment))) | ||
| 3646 | (forward-line 1) | 3664 | (forward-line 1) |
| 3647 | t)) | 3665 | t)) |
| 3648 | 3666 | ||
| @@ -7799,9 +7817,11 @@ Return the name of the output buffer used." | |||
| 7799 | markdown-command exit-code)))) | 7817 | markdown-command exit-code)))) |
| 7800 | output-buffer-name)) | 7818 | output-buffer-name)) |
| 7801 | 7819 | ||
| 7802 | (defun markdown-standalone (&optional output-buffer-name) | 7820 | (defun markdown-standalone (&optional output-buffer-name title) |
| 7803 | "Special function to provide standalone HTML output. | 7821 | "Special function to provide standalone HTML output. |
| 7804 | Insert the output in the buffer named OUTPUT-BUFFER-NAME." | 7822 | Insert the output in the buffer named OUTPUT-BUFFER-NAME. |
| 7823 | Set the HTML title to TITLE if provided, otherwise the name of the | ||
| 7824 | output buffer." | ||
| 7805 | (interactive) | 7825 | (interactive) |
| 7806 | (setq output-buffer-name (markdown output-buffer-name)) | 7826 | (setq output-buffer-name (markdown output-buffer-name)) |
| 7807 | (let ((css-path markdown-css-paths)) | 7827 | (let ((css-path markdown-css-paths)) |
| @@ -7809,7 +7829,7 @@ Insert the output in the buffer named OUTPUT-BUFFER-NAME." | |||
| 7809 | (set-buffer output-buffer-name) | 7829 | (set-buffer output-buffer-name) |
| 7810 | (setq-local markdown-css-paths css-path) | 7830 | (setq-local markdown-css-paths css-path) |
| 7811 | (unless (markdown-output-standalone-p) | 7831 | (unless (markdown-output-standalone-p) |
| 7812 | (markdown-add-xhtml-header-and-footer output-buffer-name)) | 7832 | (markdown-add-xhtml-header-and-footer (or title output-buffer-name))) |
| 7813 | (goto-char (point-min)) | 7833 | (goto-char (point-min)) |
| 7814 | (html-mode))) | 7834 | (html-mode))) |
| 7815 | output-buffer-name) | 7835 | output-buffer-name) |
| @@ -7890,7 +7910,8 @@ When OUTPUT-BUFFER-NAME is given, insert the output in the buffer with | |||
| 7890 | that name." | 7910 | that name." |
| 7891 | (interactive) | 7911 | (interactive) |
| 7892 | (browse-url-of-buffer | 7912 | (browse-url-of-buffer |
| 7893 | (markdown-standalone (or output-buffer-name markdown-output-buffer-name)))) | 7913 | (markdown-standalone (or output-buffer-name markdown-output-buffer-name) |
| 7914 | (buffer-name)))) | ||
| 7894 | 7915 | ||
| 7895 | (defun markdown-export-file-name (&optional extension) | 7916 | (defun markdown-export-file-name (&optional extension) |
| 7896 | "Attempt to generate a filename for Markdown output. | 7917 | "Attempt to generate a filename for Markdown output. |
| @@ -9773,7 +9794,7 @@ This function assumes point is on a table." | |||
| 9773 | (setq fmt (car fmtspec) fmtspec (cdr fmtspec)) | 9794 | (setq fmt (car fmtspec) fmtspec (cdr fmtspec)) |
| 9774 | (setq width (car widths) widths (cdr widths)) | 9795 | (setq width (car widths) widths (cdr widths)) |
| 9775 | (if (equal fmt 'c) | 9796 | (if (equal fmt 'c) |
| 9776 | (setq cell (concat (make-string (/ (- width (length cell)) 2) ?\s) cell))) | 9797 | (setq cell (concat (make-string (/ (- width (markdown--string-width cell)) 2) ?\s) cell))) |
| 9777 | (unless (equal fmt 'r) (setq width (- width))) | 9798 | (unless (equal fmt 'r) (setq width (- width))) |
| 9778 | (format (format " %%%ds " width) cell)) | 9799 | (format (format " %%%ds " width) cell)) |
| 9779 | cells "|"))) | 9800 | cells "|"))) |
