pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2007-2020 Jason R. Blevins and markdown-mode
|
||||
;; Copyright (C) 2007-2022 Jason R. Blevins and markdown-mode
|
||||
;; contributors (see the commit log for details).
|
||||
|
||||
;; Author: Jason R. Blevins <jblevins@xbeta.org>
|
||||
;; Maintainer: Jason R. Blevins <jblevins@xbeta.org>
|
||||
;; Created: May 24, 2007
|
||||
;; Version: 2.5-dev
|
||||
;; Package-Version: 20211022.55
|
||||
;; Package-Commit: 4469553a7395359e96b8796e1fac4de73cb6ccc4
|
||||
;; Package-Requires: ((emacs "25.1"))
|
||||
;; Version: 2.6-alpha
|
||||
;; Package-Version: 20221210.348
|
||||
;; Package-Commit: 81bd743b2bc948bacf5e177f854b3bb8bdcbbfae
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
;; Keywords: Markdown, GitHub Flavored Markdown, itex
|
||||
;; URL: https://jblevins.org/projects/markdown-mode/
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
;;; Constants =================================================================
|
||||
|
||||
(defconst markdown-mode-version "2.5-dev"
|
||||
(defconst markdown-mode-version "2.6-alpha"
|
||||
"Markdown mode version number.")
|
||||
|
||||
(defconst markdown-output-buffer-name "*markdown-output*"
|
||||
@@ -190,7 +190,7 @@ line around the header title."
|
||||
|
||||
(defcustom markdown-indent-on-enter t
|
||||
"Determines indentation behavior when pressing \\[newline].
|
||||
Possible settings are nil, t, and 'indent-and-new-item.
|
||||
Possible settings are nil, t, and \\='indent-and-new-item.
|
||||
|
||||
When non-nil, pressing \\[newline] will call `newline-and-indent'
|
||||
to indent the following line according to the context using
|
||||
@@ -198,7 +198,7 @@ to indent the following line according to the context using
|
||||
\\[electric-newline-and-maybe-indent] can still be used to insert
|
||||
a newline without indentation.
|
||||
|
||||
When set to 'indent-and-new-item and the point is in a list item
|
||||
When set to \\='indent-and-new-item and the point is in a list item
|
||||
when \\[newline] is pressed, the list will be continued on the next
|
||||
line, where a new item will be inserted.
|
||||
|
||||
@@ -492,15 +492,15 @@ completion."
|
||||
|
||||
(defcustom markdown-split-window-direction 'any
|
||||
"Preference for splitting windows for static and live preview.
|
||||
The default value is 'any, which instructs Emacs to use
|
||||
The default value is \\='any, which instructs Emacs to use
|
||||
`split-window-sensibly' to automatically choose how to split
|
||||
windows based on the values of `split-width-threshold' and
|
||||
`split-height-threshold' and the available windows. To force
|
||||
vertically split (left and right) windows, set this to 'vertical
|
||||
or 'right. To force horizontally split (top and bottom) windows,
|
||||
set this to 'horizontal or 'below.
|
||||
vertically split (left and right) windows, set this to \\='vertical
|
||||
or \\='right. To force horizontally split (top and bottom) windows,
|
||||
set this to \\='horizontal or \\='below.
|
||||
|
||||
If this value is 'any and `display-buffer-alist' is set then
|
||||
If this value is \\='any and `display-buffer-alist' is set then
|
||||
`display-buffer' is used for open buffer function"
|
||||
:group 'markdown
|
||||
:type '(choice (const :tag "Automatic" any)
|
||||
@@ -518,8 +518,8 @@ the buffer."
|
||||
|
||||
(defcustom markdown-live-preview-delete-export 'delete-on-destroy
|
||||
"Delete exported HTML file when using `markdown-live-preview-export'.
|
||||
If set to 'delete-on-export, delete on every export. When set to
|
||||
'delete-on-destroy delete when quitting from command
|
||||
If set to \\='delete-on-export, delete on every export. When set to
|
||||
\\='delete-on-destroy delete when quitting from command
|
||||
`markdown-live-preview-mode'. Never delete if set to nil."
|
||||
:group 'markdown
|
||||
:type '(choice
|
||||
@@ -639,6 +639,15 @@ This variable must be set before loading markdown-mode."
|
||||
:safe 'booleanp
|
||||
:package-version '(markdown-mode . "2.5"))
|
||||
|
||||
(defcustom markdown-fontify-whole-heading-line nil
|
||||
"Non-nil means fontify the whole line for headings.
|
||||
This is useful when setting a background color for the
|
||||
markdown-header-face-* faces."
|
||||
:group 'markdown
|
||||
:type 'boolean
|
||||
:safe 'booleanp
|
||||
:package-version '(markdown-mode . "2.5"))
|
||||
|
||||
|
||||
;;; Markdown-Specific `rx' Macro ==============================================
|
||||
|
||||
@@ -857,7 +866,7 @@ Group 3 matches the text.")
|
||||
(defconst markdown-regex-wiki-link
|
||||
"\\(?:^\\|[^\\]\\)\\(?1:\\(?2:\\[\\[\\)\\(?3:[^]|]+\\)\\(?:\\(?4:|\\)\\(?5:[^]]+\\)\\)?\\(?6:\\]\\]\\)\\)"
|
||||
"Regular expression for matching wiki links.
|
||||
This matches typical bracketed [[WikiLinks]] as well as 'aliased'
|
||||
This matches typical bracketed [[WikiLinks]] as well as \\='aliased
|
||||
wiki links of the form [[PageName|link text]].
|
||||
The meanings of the first and second components depend
|
||||
on the value of `markdown-wiki-link-alias-first'.
|
||||
@@ -997,7 +1006,7 @@ Compatible with Pandoc, Python Markdown, PHP Markdown Extra, and Leanpub.")
|
||||
"Regular expression for Leanpub section markers and related syntax.")
|
||||
|
||||
(defconst markdown-regex-sub-superscript
|
||||
"\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[[:alnum:]]+\\)\\(?4:\\2\\)\\)"
|
||||
"\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[+-\u2212]?[[:alnum:]]+\\)\\(?4:\\2\\)\\)"
|
||||
"The regular expression matching a sub- or superscript.
|
||||
The leading un-numbered group matches the character before the
|
||||
opening tilde or carat, if any, ensuring that it is not a
|
||||
@@ -1337,7 +1346,7 @@ block construct when it is matched using
|
||||
to the text matching START-REGEX-OR-FUN, END-PROPERTY to END-REGEX-OR-FUN, and
|
||||
MIDDLE-PROPERTY to the text in between the two. The value of *-PROPERTY is the
|
||||
`match-data' when the regexp was matched to the text. In the case of
|
||||
MIDDLE-PROPERTY, the value is a false match data of the form '(begin end), with
|
||||
MIDDLE-PROPERTY, the value is a false match data of the form \\='(begin end), with
|
||||
begin and end set to the edges of the \"middle\" text. This makes fontification
|
||||
easier.")
|
||||
|
||||
@@ -1576,6 +1585,13 @@ MIDDLE-BEGIN is the start of the \"middle\" section of the block."
|
||||
(put-text-property close-begin close-end
|
||||
(cl-cadadr fence-spec) close-data))))
|
||||
|
||||
(defun markdown--triple-quote-single-line-p (begin)
|
||||
(save-excursion
|
||||
(goto-char begin)
|
||||
(save-match-data
|
||||
(and (search-forward "```" nil t)
|
||||
(search-forward "```" (line-end-position) t)))))
|
||||
|
||||
(defun markdown-syntax-propertize-fenced-block-constructs (start end)
|
||||
"Propertize according to `markdown-fenced-block-pairs' from START to END.
|
||||
If unable to propertize an entire block (if the start of a block is within START
|
||||
@@ -1600,7 +1616,7 @@ start which was previously propertized."
|
||||
(markdown-maybe-funcall-regexp
|
||||
(caar correct-entry))
|
||||
(buffer-substring
|
||||
(point-at-bol) (point-at-eol)))
|
||||
(line-beginning-position) (line-end-position)))
|
||||
(- (match-end 1) (match-beginning 1))))
|
||||
(end-reg (markdown-maybe-funcall-regexp
|
||||
(cl-caadr correct-entry) start-length)))
|
||||
@@ -1610,7 +1626,8 @@ start which was previously propertized."
|
||||
(while (re-search-forward start-reg end t)
|
||||
;; we assume the opening constructs take up (only) an entire line,
|
||||
;; so we re-check the current line
|
||||
(let* ((cur-line (buffer-substring (point-at-bol) (point-at-eol)))
|
||||
(let* ((block-start (match-beginning 0))
|
||||
(cur-line (buffer-substring (line-beginning-position) (line-end-position)))
|
||||
;; find entry in `markdown-fenced-block-pairs' corresponding
|
||||
;; to regex which was matched
|
||||
(correct-entry
|
||||
@@ -1621,24 +1638,26 @@ start which was previously propertized."
|
||||
cur-line))
|
||||
markdown-fenced-block-pairs))
|
||||
(enclosed-text-start
|
||||
(save-excursion (1+ (point-at-eol))))
|
||||
(save-excursion (1+ (line-end-position))))
|
||||
(end-reg
|
||||
(markdown-maybe-funcall-regexp
|
||||
(cl-caadr correct-entry)
|
||||
(if (and (match-beginning 1) (match-end 1))
|
||||
(- (match-end 1) (match-beginning 1))
|
||||
0))))
|
||||
;; get correct match data
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(re-search-forward
|
||||
(markdown-maybe-funcall-regexp (caar correct-entry))
|
||||
(point-at-eol)))
|
||||
;; mark starting, even if ending is outside of region
|
||||
(put-text-property (match-beginning 0) (match-end 0)
|
||||
(cl-cadar correct-entry) (match-data t))
|
||||
(markdown-propertize-end-match
|
||||
end-reg end correct-entry enclosed-text-start))))))
|
||||
0)))
|
||||
(prop (cl-cadar correct-entry)))
|
||||
(when (or (not (eq prop 'markdown-gfm-block-begin))
|
||||
(not (markdown--triple-quote-single-line-p block-start)))
|
||||
;; get correct match data
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(re-search-forward
|
||||
(markdown-maybe-funcall-regexp (caar correct-entry))
|
||||
(line-end-position)))
|
||||
;; mark starting, even if ending is outside of region
|
||||
(put-text-property (match-beginning 0) (match-end 0) prop (match-data t))
|
||||
(markdown-propertize-end-match
|
||||
end-reg end correct-entry enclosed-text-start)))))))
|
||||
|
||||
(defun markdown-syntax-propertize-blockquotes (start end)
|
||||
"Match blockquotes from START to END."
|
||||
@@ -2220,6 +2239,11 @@ Depending on your font, some reasonable choices are:
|
||||
|
||||
;;; Compatibility =============================================================
|
||||
|
||||
(defun markdown--pandoc-reference-p ()
|
||||
(let ((bounds (bounds-of-thing-at-point 'word)))
|
||||
(when (and bounds (char-before (car bounds)))
|
||||
(= (char-before (car bounds)) ?@))))
|
||||
|
||||
(defun markdown-flyspell-check-word-p ()
|
||||
"Return t if `flyspell' should check word just before point.
|
||||
Used for `flyspell-generic-check-word-predicate'."
|
||||
@@ -2235,7 +2259,8 @@ Used for `flyspell-generic-check-word-predicate'."
|
||||
markdown-markup-face
|
||||
markdown-plain-url-face
|
||||
markdown-inline-code-face
|
||||
markdown-url-face)))
|
||||
markdown-url-face))
|
||||
(markdown--pandoc-reference-p))
|
||||
(prog1 nil
|
||||
;; If flyspell overlay is put, then remove it
|
||||
(let ((bounds (bounds-of-thing-at-point 'word)))
|
||||
@@ -2540,7 +2565,7 @@ the returned list would be
|
||||
(1 14 3 5 \"- \" nil (1 6 1 4 4 5 5 6))
|
||||
|
||||
If the point is not inside a list item, return nil."
|
||||
(car (get-text-property (point-at-bol) 'markdown-list-item)))
|
||||
(car (get-text-property (line-beginning-position) 'markdown-list-item)))
|
||||
|
||||
(defun markdown-list-item-at-point-p ()
|
||||
"Return t if there is a list item at the point and nil otherwise."
|
||||
@@ -2624,7 +2649,7 @@ The return value has the same form as that of
|
||||
|
||||
(defun markdown-bounds-of-thing-at-point (thing)
|
||||
"Call `bounds-of-thing-at-point' for THING with slight modifications.
|
||||
Does not include trailing newlines when THING is 'line. Handles the
|
||||
Does not include trailing newlines when THING is \\='line. Handles the
|
||||
end of buffer case by setting both endpoints equal to the value of
|
||||
`point-max', since an empty region will trigger empty markup insertion.
|
||||
Return bounds of form (beg . end) if THING is found, or nil otherwise."
|
||||
@@ -2741,7 +2766,7 @@ data. See `markdown-code-block-at-point-p' for code blocks."
|
||||
Uses text properties at the beginning of the line position.
|
||||
This includes pre blocks, tilde-fenced code blocks, and GFM
|
||||
quoted code blocks. Return nil otherwise."
|
||||
(let ((bol (save-excursion (goto-char pos) (point-at-bol))))
|
||||
(let ((bol (save-excursion (goto-char pos) (line-beginning-position))))
|
||||
(or (get-text-property bol 'markdown-pre)
|
||||
(let* ((bounds (markdown-get-enclosing-fenced-block-construct pos))
|
||||
(second (cl-second bounds)))
|
||||
@@ -2772,7 +2797,7 @@ Set match data for `markdown-regex-header'."
|
||||
(defun markdown-pipe-at-bol-p ()
|
||||
"Return non-nil if the line begins with a pipe symbol.
|
||||
This may be useful for tables and Pandoc's line_blocks extension."
|
||||
(char-equal (char-after (point-at-bol)) ?|))
|
||||
(char-equal (char-after (line-beginning-position)) ?|))
|
||||
|
||||
|
||||
;;; Markdown Font Lock Matching Functions =====================================
|
||||
@@ -2900,7 +2925,8 @@ When FACELESS is non-nil, do not return matches where faces have been applied."
|
||||
(markdown-in-comment-p)
|
||||
(markdown-range-property-any
|
||||
begin begin 'face '(markdown-url-face
|
||||
markdown-plain-url-face))
|
||||
markdown-plain-url-face
|
||||
markdown-markup-face))
|
||||
(markdown-range-property-any
|
||||
begin end 'face '(markdown-bold-face
|
||||
markdown-list-face
|
||||
@@ -2955,7 +2981,7 @@ $..$ or `markdown-regex-math-inline-double' for matching $$..$$."
|
||||
(set-match-data (cl-seventh bounds))
|
||||
;; Step at least one character beyond point. Otherwise
|
||||
;; `font-lock-fontify-keywords-region' infloops.
|
||||
(goto-char (min (1+ (max (point-at-eol) first))
|
||||
(goto-char (min (1+ (max (line-end-position) first))
|
||||
(point-max)))
|
||||
t)))
|
||||
|
||||
@@ -2972,7 +2998,8 @@ $..$ or `markdown-regex-math-inline-double' for matching $$..$$."
|
||||
(defun markdown-match-math-double (last)
|
||||
"Match double quoted $$..$$ math from point to LAST."
|
||||
(when markdown-enable-math
|
||||
(when (and (char-equal (char-after) ?$)
|
||||
(when (and (< (1+ (point)) (point-max))
|
||||
(char-equal (char-after) ?$)
|
||||
(char-equal (char-after (1+ (point))) ?$)
|
||||
(not (bolp))
|
||||
(not (char-equal (char-before) ?\\))
|
||||
@@ -3004,13 +3031,13 @@ Restore match data previously stored in PROPERTY."
|
||||
|
||||
(defun markdown-match-pre-blocks (last)
|
||||
"Match preformatted blocks from point to LAST.
|
||||
Use data stored in 'markdown-pre text property during syntax
|
||||
Use data stored in \\='markdown-pre text property during syntax
|
||||
analysis."
|
||||
(markdown-match-propertized-text 'markdown-pre last))
|
||||
|
||||
(defun markdown-match-gfm-code-blocks (last)
|
||||
"Match GFM quoted code blocks from point to LAST.
|
||||
Use data stored in 'markdown-gfm-code text property during syntax
|
||||
Use data stored in \\='markdown-gfm-code text property during syntax
|
||||
analysis."
|
||||
(markdown-match-propertized-text 'markdown-gfm-code last))
|
||||
|
||||
@@ -3032,7 +3059,7 @@ analysis."
|
||||
|
||||
(defun markdown-match-blockquotes (last)
|
||||
"Match blockquotes from point to LAST.
|
||||
Use data stored in 'markdown-blockquote text property during syntax
|
||||
Use data stored in \\='markdown-blockquote text property during syntax
|
||||
analysis."
|
||||
(markdown-match-propertized-text 'markdown-blockquote last))
|
||||
|
||||
@@ -3084,8 +3111,8 @@ processed elements."
|
||||
(match-beginning 0) (match-end 2) 'face prohibited-faces)
|
||||
(markdown-range-property-any
|
||||
(match-beginning 4) (match-end 0) 'face prohibited-faces)
|
||||
(and (char-equal (char-after (point-at-bol)) ?<)
|
||||
(char-equal (char-after (1+ (point-at-bol))) ?<)))
|
||||
(and (char-equal (char-after (line-beginning-position)) ?<)
|
||||
(char-equal (char-after (1+ (line-beginning-position))) ?<)))
|
||||
(set-match-data nil)
|
||||
(setq found t))))
|
||||
;; Match opening exclamation point (optional) and left bracket.
|
||||
@@ -3385,7 +3412,7 @@ SEQ may be an atom or a sequence."
|
||||
(margin-char-width (/ margin-pixel-width (default-font-width))))
|
||||
(set-window-margins nil margin-char-width))
|
||||
;; As a fallback, simply set margin based on character count.
|
||||
(set-window-margins nil markdown-marginalize-headers-margin-width)))
|
||||
(set-window-margins nil (1+ markdown-marginalize-headers-margin-width))))
|
||||
|
||||
(defun markdown-fontify-headings (last)
|
||||
"Add text properties to headings from point to LAST."
|
||||
@@ -3417,21 +3444,25 @@ SEQ may be an atom or a sequence."
|
||||
(add-text-properties
|
||||
(match-beginning 3) (match-end 3) rule-props)))
|
||||
;; atx heading
|
||||
(add-text-properties
|
||||
(match-beginning 4) (match-end 4) left-markup-props)
|
||||
(add-text-properties
|
||||
(match-beginning 5) (match-end 5) heading-props)
|
||||
(when (match-end 6)
|
||||
(if markdown-fontify-whole-heading-line
|
||||
(let ((header-end (min (point-max) (1+ (match-end 0)))))
|
||||
(add-text-properties
|
||||
(match-beginning 0) header-end heading-props))
|
||||
(add-text-properties
|
||||
(match-beginning 6) (match-end 6) right-markup-props))))
|
||||
(match-beginning 4) (match-end 4) left-markup-props)
|
||||
(add-text-properties
|
||||
(match-beginning 5) (match-end 5) heading-props)
|
||||
(when (match-end 6)
|
||||
(add-text-properties
|
||||
(match-beginning 6) (match-end 6) right-markup-props)))))
|
||||
t))
|
||||
|
||||
(defun markdown-fontify-tables (last)
|
||||
(when (and (re-search-forward "|" last t)
|
||||
(markdown-table-at-point-p))
|
||||
(font-lock-append-text-property
|
||||
(line-beginning-position) (min (1+ (line-end-position)) (point-max))
|
||||
'face 'markdown-table-face)
|
||||
(when (re-search-forward "|" last t)
|
||||
(when (markdown-table-at-point-p)
|
||||
(font-lock-append-text-property
|
||||
(line-beginning-position) (min (1+ (line-end-position)) (point-max))
|
||||
'face 'markdown-table-face))
|
||||
(forward-line 1)
|
||||
t))
|
||||
|
||||
@@ -3451,27 +3482,27 @@ SEQ may be an atom or a sequence."
|
||||
|
||||
(defun markdown-fontify-list-items (last)
|
||||
"Apply font-lock properties to list markers from point to LAST."
|
||||
(when (and (markdown-match-list-items last)
|
||||
(not (markdown-code-block-at-point-p (match-beginning 2))))
|
||||
(let* ((indent (length (match-string-no-properties 1)))
|
||||
(level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ...
|
||||
(bullet (nth (mod level (length markdown-list-item-bullets))
|
||||
markdown-list-item-bullets)))
|
||||
(add-text-properties
|
||||
(match-beginning 2) (match-end 2) '(face markdown-list-face))
|
||||
(when markdown-hide-markup
|
||||
(cond
|
||||
;; Unordered lists
|
||||
((string-match-p "[\\*\\+-]" (match-string 2))
|
||||
(add-text-properties
|
||||
(match-beginning 2) (match-end 2) `(display ,bullet)))
|
||||
;; Definition lists
|
||||
((string-equal ":" (match-string 2))
|
||||
(let ((display-string
|
||||
(char-to-string (markdown--first-displayable
|
||||
markdown-definition-display-char))))
|
||||
(add-text-properties (match-beginning 2) (match-end 2)
|
||||
`(display ,display-string)))))))
|
||||
(when (markdown-match-list-items last)
|
||||
(when (not (markdown-code-block-at-point-p (match-beginning 2)))
|
||||
(let* ((indent (length (match-string-no-properties 1)))
|
||||
(level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ...
|
||||
(bullet (nth (mod level (length markdown-list-item-bullets))
|
||||
markdown-list-item-bullets)))
|
||||
(add-text-properties
|
||||
(match-beginning 2) (match-end 2) '(face markdown-list-face))
|
||||
(when markdown-hide-markup
|
||||
(cond
|
||||
;; Unordered lists
|
||||
((string-match-p "[\\*\\+-]" (match-string 2))
|
||||
(add-text-properties
|
||||
(match-beginning 2) (match-end 2) `(display ,bullet)))
|
||||
;; Definition lists
|
||||
((string-equal ":" (match-string 2))
|
||||
(let ((display-string
|
||||
(char-to-string (markdown--first-displayable
|
||||
markdown-definition-display-char))))
|
||||
(add-text-properties (match-beginning 2) (match-end 2)
|
||||
`(display ,display-string))))))))
|
||||
t))
|
||||
|
||||
(defun markdown-fontify-hrs (last)
|
||||
@@ -4450,13 +4481,13 @@ code block in an indirect buffer after insertion."
|
||||
(markdown-ensure-blank-line-before)
|
||||
(indent-to indent)
|
||||
(insert "```" gfm-open-brace lang gfm-close-brace)
|
||||
(markdown-syntax-propertize-fenced-block-constructs (point-at-bol) end))
|
||||
(markdown-syntax-propertize-fenced-block-constructs (line-beginning-position) end))
|
||||
(let ((indent (current-indentation))
|
||||
start-bol)
|
||||
(delete-horizontal-space :backward-only)
|
||||
(markdown-ensure-blank-line-before)
|
||||
(indent-to indent)
|
||||
(setq start-bol (point-at-bol))
|
||||
(setq start-bol (line-beginning-position))
|
||||
(insert "```" gfm-open-brace lang gfm-close-brace "\n")
|
||||
(indent-to indent)
|
||||
(unless edit (insert ?\n))
|
||||
@@ -4509,7 +4540,7 @@ at the beginning of the block."
|
||||
(defun markdown-insert-foldable-block ()
|
||||
"Insert details disclosure element to make content foldable.
|
||||
If a region is active, wrap this region with the disclosure
|
||||
element. More detais here 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details'."
|
||||
element. More detais here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details."
|
||||
(interactive)
|
||||
(let ((details-open-tag "<details>")
|
||||
(details-close-tag "</details>")
|
||||
@@ -4954,7 +4985,7 @@ If the point is at a table, move to the next row. Otherwise,
|
||||
indent according to value of `markdown-indent-on-enter'.
|
||||
When it is nil, simply call `newline'. Otherwise, indent the next line
|
||||
following RET using `markdown-indent-line'. Furthermore, when it
|
||||
is set to 'indent-and-new-item and the point is in a list item,
|
||||
is set to \\='indent-and-new-item and the point is in a list item,
|
||||
start a new item with the same indentation. If the point is in an
|
||||
empty list item, remove it (so that pressing RET twice when in a
|
||||
list simply adds a blank line)."
|
||||
@@ -5758,7 +5789,7 @@ See `imenu-create-index-function' and `imenu--index-alist' for details."
|
||||
;; Headings
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward markdown-regex-header (point-max) t)
|
||||
(when (and (not (markdown-code-block-at-point-p (point-at-bol)))
|
||||
(when (and (not (markdown-code-block-at-point-p (line-beginning-position)))
|
||||
(not (markdown-text-property-at-point 'markdown-yaml-metadata-begin)))
|
||||
(cond
|
||||
((setq heading (match-string-no-properties 1))
|
||||
@@ -6208,7 +6239,7 @@ increase the indentation by one level."
|
||||
((string-match-p "[\\*\\+-]\\|#\\." marker)
|
||||
(insert new-indent marker))))
|
||||
;; Propertize the newly inserted list item now
|
||||
(markdown-syntax-propertize-list-items (point-at-bol) (point-at-eol)))))
|
||||
(markdown-syntax-propertize-list-items (line-beginning-position) (line-end-position)))))
|
||||
|
||||
(defun markdown-move-list-item-up ()
|
||||
"Move the current list item up in the list when possible.
|
||||
@@ -6458,7 +6489,7 @@ means move forward N blocks."
|
||||
(beginning-of-line)
|
||||
;; Skip over code block endings.
|
||||
(when (markdown-range-properties-exist
|
||||
(point-at-bol) (point-at-eol)
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(markdown-gfm-block-end
|
||||
markdown-tilde-fence-end))
|
||||
(forward-line -1))
|
||||
@@ -6487,11 +6518,11 @@ means move forward N blocks."
|
||||
(not (markdown-cur-line-blank-p))
|
||||
(not (looking-at markdown-regex-blockquote))
|
||||
(not (markdown-range-properties-exist
|
||||
(point-at-bol) (point-at-eol)
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(markdown-gfm-block-end
|
||||
markdown-tilde-fence-end))))
|
||||
(setq skip (markdown-range-properties-exist
|
||||
(point-at-bol) (point-at-eol)
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(markdown-gfm-block-begin
|
||||
markdown-tilde-fence-begin)))
|
||||
(forward-line -1))
|
||||
@@ -6538,11 +6569,11 @@ means move backward N blocks."
|
||||
(not (markdown-cur-line-blank-p))
|
||||
(not (looking-at markdown-regex-blockquote))
|
||||
(not (markdown-range-properties-exist
|
||||
(point-at-bol) (point-at-eol)
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(markdown-gfm-block-begin
|
||||
markdown-tilde-fence-begin))))
|
||||
(setq skip (markdown-range-properties-exist
|
||||
(point-at-bol) (point-at-eol)
|
||||
(line-beginning-position) (line-end-position)
|
||||
'(markdown-gfm-block-end
|
||||
markdown-tilde-fence-end)))
|
||||
(forward-line))))))))
|
||||
@@ -6566,7 +6597,7 @@ ARG = -N means move forward N blocks."
|
||||
(cond
|
||||
;; Code blocks
|
||||
((and (markdown-code-block-at-pos (point)) ;; this line
|
||||
(markdown-code-block-at-pos (point-at-bol 0))) ;; previous line
|
||||
(markdown-code-block-at-pos (line-beginning-position 0))) ;; previous line
|
||||
(forward-line -1)
|
||||
(while (and (markdown-code-block-at-point-p) (not (bobp)))
|
||||
(forward-line -1))
|
||||
@@ -6821,7 +6852,7 @@ Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
|
||||
|
||||
(defun markdown-on-heading-p ()
|
||||
"Return non-nil if point is on a heading line."
|
||||
(get-text-property (point-at-bol) 'markdown-heading))
|
||||
(get-text-property (line-beginning-position) 'markdown-heading))
|
||||
|
||||
(defun markdown-end-of-subtree (&optional invisible-OK)
|
||||
"Move to the end of the current subtree.
|
||||
@@ -6867,7 +6898,7 @@ setext header, but should not be folded."
|
||||
(outline-next-visible-heading 1))
|
||||
(while (< (point) (point-max))
|
||||
(when (markdown-code-block-at-point-p)
|
||||
(outline-flag-region (1- (point-at-bol)) (point-at-eol) t))
|
||||
(outline-flag-region (1- (line-beginning-position)) (line-end-position) t))
|
||||
(outline-next-visible-heading 1))))
|
||||
|
||||
(defvar markdown-cycle-global-status 1)
|
||||
@@ -7342,7 +7373,11 @@ Return the name of the output buffer used."
|
||||
(if (not (null command-args))
|
||||
(apply #'call-process-region begin-region end-region command nil buf nil command-args)
|
||||
(call-process-region begin-region end-region command nil buf))
|
||||
(funcall markdown-command begin-region end-region buf)
|
||||
(if markdown-command-needs-filename
|
||||
(if (not buffer-file-name)
|
||||
(user-error "Must be visiting a file")
|
||||
(funcall markdown-command begin-region end-region buf buffer-file-name))
|
||||
(funcall markdown-command begin-region end-region buf))
|
||||
;; If the ‘markdown-command’ function didn’t signal an
|
||||
;; error, assume it succeeded by binding ‘exit-code’ to 0.
|
||||
0))))))
|
||||
@@ -7508,8 +7543,17 @@ This is the inverse of `markdown-live-preview-buffer'.")
|
||||
(defun markdown-live-preview-window-eww (file)
|
||||
"Preview FILE with eww.
|
||||
To be used with `markdown-live-preview-window-function'."
|
||||
(when (and (bound-and-true-p eww-auto-rename-buffer)
|
||||
markdown-live-preview-buffer)
|
||||
(kill-buffer markdown-live-preview-buffer))
|
||||
(eww-open-file file)
|
||||
(get-buffer "*eww*"))
|
||||
;; #737 if `eww-auto-rename-buffer' is non-nil, the buffer name is not "*eww*"
|
||||
;; Try to find the buffer whose name ends with "eww*"
|
||||
(if (bound-and-true-p eww-auto-rename-buffer)
|
||||
(cl-loop for buf in (buffer-list)
|
||||
when (string-match-p "eww\\*\\'" (buffer-name buf))
|
||||
return buf)
|
||||
(get-buffer "*eww*")))
|
||||
|
||||
(defun markdown-visual-lines-between-points (beg end)
|
||||
(save-excursion
|
||||
@@ -7646,20 +7690,19 @@ displaying the rendered output."
|
||||
(setq markdown-live-preview-source-buffer nil))))
|
||||
|
||||
(defun markdown-live-preview-switch-to-output ()
|
||||
"Switch to output buffer."
|
||||
"Turn on `markdown-live-preview-mode' and switch to output buffer.
|
||||
The output buffer is opened in another window."
|
||||
(interactive)
|
||||
"Turn on `markdown-live-preview-mode' if not already on, and switch to its
|
||||
output buffer in another window."
|
||||
(if markdown-live-preview-mode
|
||||
(markdown-display-buffer-other-window (markdown-live-preview-export)))
|
||||
(markdown-live-preview-mode))
|
||||
|
||||
(defun markdown-live-preview-re-export ()
|
||||
"Re export source buffer."
|
||||
(interactive)
|
||||
"If the current buffer is a buffer displaying the exported version of a
|
||||
"Re-export the current live previewed content.
|
||||
If the current buffer is a buffer displaying the exported version of a
|
||||
`markdown-live-preview-mode' buffer, call `markdown-live-preview-export' and
|
||||
update this buffer's contents."
|
||||
(interactive)
|
||||
(when markdown-live-preview-source-buffer
|
||||
(with-current-buffer markdown-live-preview-source-buffer
|
||||
(markdown-live-preview-export))))
|
||||
@@ -7816,8 +7859,7 @@ Translate filenames using `markdown-filename-translate-function'."
|
||||
(title-end (match-end 7))
|
||||
(title (match-string-no-properties 7))
|
||||
;; Markup part
|
||||
(mp (list 'face 'markdown-markup-face
|
||||
'invisible 'markdown-markup
|
||||
(mp (list 'invisible 'markdown-markup
|
||||
'rear-nonsticky t
|
||||
'font-lock-multiline t))
|
||||
;; Link part (without face)
|
||||
@@ -7827,26 +7869,28 @@ Translate filenames using `markdown-filename-translate-function'."
|
||||
'help-echo (if title (concat title "\n" url) url)))
|
||||
;; URL part
|
||||
(up (list 'keymap markdown-mode-mouse-map
|
||||
'face 'markdown-url-face
|
||||
'invisible 'markdown-markup
|
||||
'mouse-face 'markdown-highlight-face
|
||||
'font-lock-multiline t))
|
||||
;; URL composition character
|
||||
(url-char (markdown--first-displayable markdown-url-compose-char))
|
||||
;; Title part
|
||||
(tp (list 'face 'markdown-link-title-face
|
||||
'invisible 'markdown-markup
|
||||
(tp (list 'invisible 'markdown-markup
|
||||
'font-lock-multiline t)))
|
||||
(dolist (g '(1 2 4 5 8))
|
||||
(when (match-end g)
|
||||
(add-text-properties (match-beginning g) (match-end g) mp)))
|
||||
(add-text-properties (match-beginning g) (match-end g) mp)
|
||||
(add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face)))
|
||||
;; Preserve existing faces applied to link part (e.g., inline code)
|
||||
(when link-start
|
||||
(add-text-properties link-start link-end lp)
|
||||
(add-face-text-property link-start link-end
|
||||
'markdown-link-face 'append))
|
||||
(when url-start (add-text-properties url-start url-end up))
|
||||
(when title-start (add-text-properties url-end title-end tp))
|
||||
(add-face-text-property link-start link-end 'markdown-link-face))
|
||||
(when url-start
|
||||
(add-text-properties url-start url-end up)
|
||||
(add-face-text-property url-start url-end 'markdown-url-face))
|
||||
(when title-start
|
||||
(add-text-properties url-end title-end tp)
|
||||
(add-face-text-property url-end title-end 'markdown-link-title-face))
|
||||
(when (and markdown-hide-urls url-start)
|
||||
(compose-region url-start (or title-end url-end) url-char))
|
||||
t)))
|
||||
@@ -7859,13 +7903,11 @@ Translate filenames using `markdown-filename-translate-function'."
|
||||
(ref-start (match-beginning 6))
|
||||
(ref-end (match-end 6))
|
||||
;; Markup part
|
||||
(mp (list 'face 'markdown-markup-face
|
||||
'invisible 'markdown-markup
|
||||
(mp (list 'invisible 'markdown-markup
|
||||
'rear-nonsticky t
|
||||
'font-lock-multiline t))
|
||||
;; Link part
|
||||
(lp (list 'keymap markdown-mode-mouse-map
|
||||
'face 'markdown-link-face
|
||||
'mouse-face 'markdown-highlight-face
|
||||
'font-lock-multiline t
|
||||
'help-echo (lambda (_ __ pos)
|
||||
@@ -7877,16 +7919,20 @@ Translate filenames using `markdown-filename-translate-function'."
|
||||
;; URL composition character
|
||||
(url-char (markdown--first-displayable markdown-url-compose-char))
|
||||
;; Reference part
|
||||
(rp (list 'face 'markdown-reference-face
|
||||
'invisible 'markdown-markup
|
||||
(rp (list 'invisible 'markdown-markup
|
||||
'font-lock-multiline t)))
|
||||
(dolist (g '(1 2 4 5 8))
|
||||
(when (match-end g)
|
||||
(add-text-properties (match-beginning g) (match-end g) mp)))
|
||||
(when link-start (add-text-properties link-start link-end lp))
|
||||
(when ref-start (add-text-properties ref-start ref-end rp)
|
||||
(when (and markdown-hide-urls (> (- ref-end ref-start) 2))
|
||||
(compose-region ref-start ref-end url-char)))
|
||||
(add-text-properties (match-beginning g) (match-end g) mp)
|
||||
(add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face)))
|
||||
(when link-start
|
||||
(add-text-properties link-start link-end lp)
|
||||
(add-face-text-property link-start link-end 'markdown-link-face))
|
||||
(when ref-start
|
||||
(add-text-properties ref-start ref-end rp)
|
||||
(add-face-text-property ref-start ref-end 'markdown-reference-face)
|
||||
(when (and markdown-hide-urls (> (- ref-end ref-start) 2))
|
||||
(compose-region ref-start ref-end url-char)))
|
||||
t)))
|
||||
|
||||
(defun markdown-fontify-angle-uris (last)
|
||||
@@ -8122,13 +8168,13 @@ newline after."
|
||||
(let* ((modified (buffer-modified-p))
|
||||
(buffer-undo-list t)
|
||||
(inhibit-read-only t)
|
||||
(inhibit-point-motion-hooks t)
|
||||
deactivate-mark
|
||||
buffer-file-truename)
|
||||
(unwind-protect
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(save-restriction
|
||||
(cursor-intangible-mode +1) ;; inhibit-point-motion-hooks is obsoleted since Emacs 29
|
||||
;; Extend the region to fontify so that it starts
|
||||
;; and ends at safe places.
|
||||
(cl-multiple-value-bind (new-from new-to)
|
||||
@@ -8145,6 +8191,7 @@ newline after."
|
||||
(markdown-unfontify-region-wiki-links new-from new-to)
|
||||
;; Now do the fontification.
|
||||
(markdown-fontify-region-wiki-links new-from new-to))))))
|
||||
(cursor-intangible-mode -1)
|
||||
(and (not modified)
|
||||
(buffer-modified-p)
|
||||
(set-buffer-modified-p nil)))))
|
||||
@@ -8345,7 +8392,7 @@ return the number of paragraphs left to move."
|
||||
(while (and (not (eobp))
|
||||
(> arg 0)
|
||||
(= (forward-paragraph 1) 0)
|
||||
(or (markdown-code-block-at-pos (point-at-bol 0))
|
||||
(or (markdown-code-block-at-pos (line-beginning-position 0))
|
||||
(setq arg (1- arg)))))
|
||||
;; Move backward by one paragraph with negative ARG (always -1).
|
||||
(let ((start (point)))
|
||||
@@ -8363,7 +8410,7 @@ return the number of paragraphs left to move."
|
||||
((looking-at "^|\\s-*")
|
||||
(goto-char (match-end 0)))
|
||||
;; Return point if the paragraph passed was a code block.
|
||||
((markdown-code-block-at-pos (point-at-bol 2))
|
||||
((markdown-code-block-at-pos (line-beginning-position 2))
|
||||
(goto-char start)))))
|
||||
arg)
|
||||
|
||||
@@ -8489,7 +8536,7 @@ Returns nil if non-applicable."
|
||||
(insert markup))
|
||||
(goto-char pos)
|
||||
(insert markup))
|
||||
(syntax-propertize (point-at-eol))
|
||||
(syntax-propertize (line-end-position))
|
||||
t)))))
|
||||
|
||||
(defun markdown-toggle-gfm-checkbox ()
|
||||
@@ -8724,9 +8771,9 @@ Use matching function MATCHER."
|
||||
(end (match-end 0))
|
||||
;; Find positions outside opening and closing backquotes.
|
||||
(bol-prev (progn (goto-char start)
|
||||
(if (bolp) (point-at-bol 0) (point-at-bol))))
|
||||
(if (bolp) (line-beginning-position 0) (line-beginning-position))))
|
||||
(eol-next (progn (goto-char end)
|
||||
(if (bolp) (point-at-bol 2) (point-at-bol 3))))
|
||||
(if (bolp) (line-beginning-position 2) (line-beginning-position 3))))
|
||||
lang)
|
||||
(if (and markdown-fontify-code-blocks-natively
|
||||
(or (setq lang (markdown-code-block-lang))
|
||||
@@ -8812,8 +8859,8 @@ at the END of code blocks."
|
||||
(save-excursion
|
||||
(if (fboundp 'edit-indirect-region)
|
||||
(let* ((bounds (markdown-get-enclosing-fenced-block-construct))
|
||||
(begin (and bounds (not (null (nth 0 bounds))) (goto-char (nth 0 bounds)) (point-at-bol 2)))
|
||||
(end (and bounds(not (null (nth 1 bounds))) (goto-char (nth 1 bounds)) (point-at-bol 1))))
|
||||
(begin (and bounds (not (null (nth 0 bounds))) (goto-char (nth 0 bounds)) (line-beginning-position 2)))
|
||||
(end (and bounds(not (null (nth 1 bounds))) (goto-char (nth 1 bounds)) (line-beginning-position 1))))
|
||||
(if (and begin end)
|
||||
(let* ((indentation (and (goto-char (nth 0 bounds)) (current-indentation)))
|
||||
(lang (markdown-code-block-lang))
|
||||
@@ -9018,7 +9065,7 @@ This function assumes point is on a table."
|
||||
(while (and (re-search-forward
|
||||
markdown-table-dline-regexp end t)
|
||||
(setq cnt (1+ cnt))
|
||||
(< (point-at-eol) pos))))
|
||||
(< (line-end-position) pos))))
|
||||
cnt))
|
||||
|
||||
(defun markdown--thing-at-wiki-link (pos)
|
||||
@@ -9049,7 +9096,7 @@ a table."
|
||||
(if (looking-at "|[^|\r\n]*")
|
||||
(let* ((pos (match-beginning 0))
|
||||
(val (buffer-substring (1+ pos) (match-end 0))))
|
||||
(goto-char (min (point-at-eol) (+ 2 pos)))
|
||||
(goto-char (min (line-end-position) (+ 2 pos)))
|
||||
;; Trim whitespaces
|
||||
(setq val (replace-regexp-in-string "\\`[ \t]+" "" val)
|
||||
val (replace-regexp-in-string "[ \t]+\\'" "" val)))
|
||||
@@ -9074,7 +9121,7 @@ beyond the last delimiter. This function assumes point is on a
|
||||
table."
|
||||
(beginning-of-line 1)
|
||||
(when (> n 0)
|
||||
(while (and (> n 0) (search-forward "|" (point-at-eol) t))
|
||||
(while (and (> n 0) (search-forward "|" (line-end-position) t))
|
||||
(when (and (not (looking-back "\\\\|" (line-beginning-position)))
|
||||
(not (markdown--thing-at-wiki-link (match-beginning 0))))
|
||||
(cl-decf n)))
|
||||
@@ -9229,8 +9276,8 @@ With optional argument ARG, insert below the current row."
|
||||
(unless (markdown-table-at-point-p)
|
||||
(user-error "Not at a table"))
|
||||
(let ((col (current-column)))
|
||||
(kill-region (point-at-bol)
|
||||
(min (1+ (point-at-eol)) (point-max)))
|
||||
(kill-region (line-beginning-position)
|
||||
(min (1+ (line-end-position)) (point-max)))
|
||||
(unless (markdown-table-at-point-p) (beginning-of-line 0))
|
||||
(move-to-column col)))
|
||||
|
||||
@@ -9246,8 +9293,8 @@ With optional argument UP, move it up."
|
||||
(unless (markdown-table-at-point-p)
|
||||
(goto-char pos) (user-error "Cannot move row further"))
|
||||
(goto-char pos) (beginning-of-line 1) (setq pos (point))
|
||||
(setq txt (buffer-substring (point) (1+ (point-at-eol))))
|
||||
(delete-region (point) (1+ (point-at-eol)))
|
||||
(setq txt (buffer-substring (point) (1+ (line-end-position))))
|
||||
(delete-region (point) (1+ (line-end-position)))
|
||||
(beginning-of-line tonew)
|
||||
(insert txt) (beginning-of-line 0)
|
||||
(move-to-column col)))
|
||||
@@ -9624,7 +9671,7 @@ rows and columns and the column alignment."
|
||||
(make-list columns (concat align "|")))))
|
||||
(if (string-match
|
||||
"^[ \t]*$" (buffer-substring-no-properties
|
||||
(point-at-bol) (point)))
|
||||
(line-beginning-position) (point)))
|
||||
(beginning-of-line 1)
|
||||
(newline))
|
||||
(dotimes (_ rows) (insert line))
|
||||
@@ -9637,7 +9684,7 @@ rows and columns and the column alignment."
|
||||
|
||||
;;; ElDoc Support =============================================================
|
||||
|
||||
(defun markdown-eldoc-function ()
|
||||
(defun markdown-eldoc-function (&rest _ignored)
|
||||
"Return a helpful string when appropriate based on context.
|
||||
* Report URL when point is at a hidden URL.
|
||||
* Report language name when point is a code block with hidden markup."
|
||||
@@ -9647,22 +9694,21 @@ rows and columns and the column alignment."
|
||||
(thing-at-point-looking-at markdown-regex-link-reference))
|
||||
(or markdown-hide-urls markdown-hide-markup))
|
||||
(let* ((imagep (string-equal (match-string 1) "!"))
|
||||
(referencep (string-equal (match-string 5) "["))
|
||||
(link (match-string-no-properties 6))
|
||||
(edit-keys (markdown--substitute-command-keys
|
||||
(if imagep
|
||||
"\\[markdown-insert-image]"
|
||||
"\\[markdown-insert-link]")))
|
||||
(edit-str (propertize edit-keys 'face 'font-lock-constant-face))
|
||||
(referencep (string-equal (match-string 5) "["))
|
||||
(object (if referencep "reference" "URL")))
|
||||
(format "Hidden %s (%s to edit): %s" object edit-str
|
||||
(if referencep
|
||||
(concat
|
||||
(propertize "[" 'face 'markdown-markup-face)
|
||||
(propertize (match-string-no-properties 6)
|
||||
'face 'markdown-reference-face)
|
||||
(propertize link 'face 'markdown-reference-face)
|
||||
(propertize "]" 'face 'markdown-markup-face))
|
||||
(propertize (match-string-no-properties 6)
|
||||
'face 'markdown-url-face)))))
|
||||
(propertize link 'face 'markdown-url-face)))))
|
||||
;; Hidden language name for fenced code blocks
|
||||
((and (markdown-code-block-at-point-p)
|
||||
(not (get-text-property (point) 'markdown-pre))
|
||||
@@ -9778,8 +9824,10 @@ rows and columns and the column alignment."
|
||||
;; Cause use of ellipses for invisible text.
|
||||
(add-to-invisibility-spec '(outline . t))
|
||||
;; ElDoc support
|
||||
(add-function :before-until (local 'eldoc-documentation-function)
|
||||
#'markdown-eldoc-function)
|
||||
(if (boundp 'eldoc-documentation-functions)
|
||||
(add-hook 'eldoc-documentation-functions #'markdown-eldoc-function nil t)
|
||||
(add-function :before-until (local 'eldoc-documentation-function)
|
||||
#'markdown-eldoc-function))
|
||||
;; Inhibiting line-breaking:
|
||||
;; Separating out each condition into a separate function so that users can
|
||||
;; override if desired (with remove-hook)
|
||||
|
||||
Reference in New Issue
Block a user