summaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
authorSimeon Simeonov2025-05-11 22:43:09 +0200
committerSimeon Simeonov2025-05-11 22:43:09 +0200
commite5b13f21317f6209b515caa8b9c9f22a98000333 (patch)
treecc200f574f9a068136b188559a6a93625515691f /.emacs.d
parenta429db57b6fc60d6bd026bd530cdb80554101622 (diff)
Upgrade markdown-mode and yasnippet
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/markdown-mode.el305
-rw-r--r--.emacs.d/lisp/yasnippet.el73
2 files changed, 242 insertions, 136 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el
index 311050f..671210e 100644
--- a/.emacs.d/lisp/markdown-mode.el
+++ b/.emacs.d/lisp/markdown-mode.el
@@ -263,11 +263,11 @@ This is the default search behavior of Ikiwiki."
263 :package-version '(markdown-mode . "2.2")) 263 :package-version '(markdown-mode . "2.2"))
264 264
265(defcustom markdown-wiki-link-search-type nil 265(defcustom markdown-wiki-link-search-type nil
266 "Searching type for markdown wiki link. 266 "A list of options for searching for markdown wiki links.
267 267
268sub-directories: search for wiki link targets in sub directories 268`sub-directories': search for wiki link targets in sub directories
269parent-directories: search for wiki link targets in parent directories 269`parent-directories': search for wiki link targets in parent directories
270project: search for wiki link targets under project root" 270`project': search for wiki link targets under project root"
271 :group 'markdown 271 :group 'markdown
272 :type '(set 272 :type '(set
273 (const :tag "search wiki link from subdirectories" sub-directories) 273 (const :tag "search wiki link from subdirectories" sub-directories)
@@ -278,6 +278,16 @@ project: search for wiki link targets under project root"
278(make-obsolete-variable 'markdown-wiki-link-search-subdirectories 'markdown-wiki-link-search-type "2.5") 278(make-obsolete-variable 'markdown-wiki-link-search-subdirectories 'markdown-wiki-link-search-type "2.5")
279(make-obsolete-variable 'markdown-wiki-link-search-parent-directories 'markdown-wiki-link-search-type "2.5") 279(make-obsolete-variable 'markdown-wiki-link-search-parent-directories 'markdown-wiki-link-search-type "2.5")
280 280
281(make-obsolete 'markdown-match-wiki-link nil "2.8")
282(make-obsolete 'markdown-highlight-wiki-link nil "2.8")
283(make-obsolete 'markdown-unfontify-region-wiki-links nil "2.8")
284(make-obsolete 'markdown-fontify-region-wiki-links nil "2.8")
285(make-obsolete 'markdown-extend-changed-region nil "2.8")
286(make-obsolete 'markdown-check-change-for-wiki-link nil "2.8")
287(make-obsolete 'markdown-check-change-for-wiki-link-after-change nil "2.8")
288(make-obsolete 'markdown-fontify-buffer-wiki-links nil "2.8")
289(make-obsolete 'markdown-setup-wiki-link-hooks nil "2.8")
290
281(defcustom markdown-wiki-link-fontify-missing nil 291(defcustom markdown-wiki-link-fontify-missing nil
282 "When non-nil, change wiki link face according to existence of target files. 292 "When non-nil, change wiki link face according to existence of target files.
283This is expensive because it requires checking for the file each time the buffer 293This is expensive because it requires checking for the file each time the buffer
@@ -930,7 +940,6 @@ This matches typical bracketed [[WikiLinks]] as well as \\='aliased
930wiki links of the form [[PageName|link text]]. 940wiki links of the form [[PageName|link text]].
931The meanings of the first and second components depend 941The meanings of the first and second components depend
932on the value of `markdown-wiki-link-alias-first'. 942on the value of `markdown-wiki-link-alias-first'.
933
934Group 1 matches the entire link. 943Group 1 matches the entire link.
935Group 2 matches the opening square brackets. 944Group 2 matches the opening square brackets.
936Group 3 matches the first component of the wiki link. 945Group 3 matches the first component of the wiki link.
@@ -2007,12 +2016,14 @@ inline code fragments and code blocks."
2007 2016
2008(defface markdown-link-face 2017(defface markdown-link-face
2009 '((t (:inherit link))) 2018 '((t (:inherit link)))
2010 "Face for links." 2019 "Face for link text, ie the alias portion of a link.
2020If a wiki link does not have an alias portion, use this face
2021for the entire link."
2011 :group 'markdown-faces) 2022 :group 'markdown-faces)
2012 2023
2013(defface markdown-missing-link-face 2024(defface markdown-missing-link-face
2014 '((t (:inherit font-lock-warning-face))) 2025 '((t (:inherit font-lock-warning-face)))
2015 "Face for missing links." 2026 "Face for the link text if the link points to a missing file."
2016 :group 'markdown-faces) 2027 :group 'markdown-faces)
2017 2028
2018(defface markdown-reference-face 2029(defface markdown-reference-face
@@ -2283,6 +2294,7 @@ Depending on your font, some reasonable choices are:
2283 (7 markdown-markup-properties))) 2294 (7 markdown-markup-properties)))
2284 (markdown-fontify-inline-links) 2295 (markdown-fontify-inline-links)
2285 (markdown-fontify-reference-links) 2296 (markdown-fontify-reference-links)
2297 (markdown-fontify-wiki-links)
2286 (,markdown-regex-reference-definition . ((1 'markdown-markup-face) ; [ 2298 (,markdown-regex-reference-definition . ((1 'markdown-markup-face) ; [
2287 (2 'markdown-reference-face) ; label 2299 (2 'markdown-reference-face) ; label
2288 (3 'markdown-markup-face) ; ] 2300 (3 'markdown-markup-face) ; ]
@@ -2319,8 +2331,7 @@ Depending on your font, some reasonable choices are:
2319 (markdown-fontify-sub-superscripts) 2331 (markdown-fontify-sub-superscripts)
2320 (markdown-match-inline-attributes . ((0 markdown-markup-properties prepend))) 2332 (markdown-match-inline-attributes . ((0 markdown-markup-properties prepend)))
2321 (markdown-match-leanpub-sections . ((0 markdown-markup-properties))) 2333 (markdown-match-leanpub-sections . ((0 markdown-markup-properties)))
2322 (markdown-fontify-blockquotes) 2334 (markdown-fontify-blockquotes))
2323 (markdown-match-wiki-link . ((0 'markdown-link-face prepend))))
2324 "Syntax highlighting for Markdown files.") 2335 "Syntax highlighting for Markdown files.")
2325 2336
2326;; Footnotes 2337;; Footnotes
@@ -3422,7 +3433,8 @@ the buffer)."
3422 (markdown-code-block-at-pos begin)) 3433 (markdown-code-block-at-pos begin))
3423 (progn (goto-char (min (1+ begin) last)) 3434 (progn (goto-char (min (1+ begin) last))
3424 (when (< (point) last) 3435 (when (< (point) last)
3425 (markdown-match-wiki-link last))) 3436 (with-no-warnings
3437 (markdown-match-wiki-link last))))
3426 (set-match-data (list begin end)) 3438 (set-match-data (list begin end))
3427 t)))) 3439 t))))
3428 3440
@@ -3709,6 +3721,18 @@ SEQ may be an atom or a sequence."
3709(defvar markdown-mode-syntax-table 3721(defvar markdown-mode-syntax-table
3710 (let ((tab (make-syntax-table text-mode-syntax-table))) 3722 (let ((tab (make-syntax-table text-mode-syntax-table)))
3711 (modify-syntax-entry ?\" "." tab) 3723 (modify-syntax-entry ?\" "." tab)
3724 (modify-syntax-entry ?$ "." tab) ; Might appear in inline content
3725 (modify-syntax-entry ?% "." tab) ; Could appear in URLs
3726 (modify-syntax-entry ?* "." tab) ; Emphasis (bold/italic)
3727 (modify-syntax-entry ?+ "." tab) ; Used in lists
3728 (modify-syntax-entry ?/ "." tab) ; Might appear in inline content or URLs
3729 (modify-syntax-entry ?< "." tab) ; For autolinks and embedded HTML
3730 (modify-syntax-entry ?= "." tab) ; Underlining in setext headers
3731 (modify-syntax-entry ?> "." tab) ; Blockquotes and HTML
3732 (modify-syntax-entry ?_ "." tab) ; Used for emphasis/bold
3733 (modify-syntax-entry ?| "." tab) ; Used in tables
3734 (modify-syntax-entry ?& "." tab) ; HTML entities
3735 (modify-syntax-entry ?' "." tab) ; Apostrophe as punctuation
3712 tab) 3736 tab)
3713 "Syntax table for `markdown-mode'.") 3737 "Syntax table for `markdown-mode'.")
3714 3738
@@ -5254,8 +5278,7 @@ Otherwise, do normal delete by repeating
5254 (back-to-indentation) 5278 (back-to-indentation)
5255 (unless (looking-at-p "[ \t]*$") 5279 (unless (looking-at-p "[ \t]*$")
5256 (setq mincol (min mincol (current-column)))) 5280 (setq mincol (min mincol (current-column))))
5257 (forward-line 1) 5281 (forward-line 1)))
5258 ))
5259 mincol)) 5282 mincol))
5260 5283
5261(defun markdown-indent-region (beg end arg) 5284(defun markdown-indent-region (beg end arg)
@@ -5730,7 +5753,39 @@ Assumes match data is available for `markdown-regex-italic'."
5730 "Keymap for `gfm-mode'. 5753 "Keymap for `gfm-mode'.
5731See also `markdown-mode-map'.") 5754See also `markdown-mode-map'.")
5732 5755
5733 5756
5757;;; Text Properties ===========================================================
5758
5759(defconst markdown--markup-props (list 'invisible 'markdown-markup
5760 'rear-nonsticky t
5761 'font-lock-multiline t))
5762
5763(defconst markdown--title-props (list 'invisible 'markdown-markup
5764 'font-lock-multiline t))
5765
5766(defun markdown--url-props ()
5767 (if markdown-mouse-follow-link
5768 (list 'invisible 'markdown-markup
5769 'keymap markdown-mode-mouse-map
5770 'mouse-face 'markdown-highlight-face
5771 'font-lock-multiline t)
5772 (list 'invisible 'markdown-markup
5773 'keymap markdown-mode-mouse-map
5774 'font-lock-multiline t)))
5775
5776(defun markdown--link-props (url &optional title)
5777 "Return a property list for URL with optional TITLE."
5778 (let ((echo-text (if title (concat title "\n" url) url)))
5779 (if markdown-mouse-follow-link
5780 (list 'keymap markdown-mode-mouse-map
5781 'mouse-face 'markdown-highlight-face
5782 'font-lock-multiline t
5783 'help-echo echo-text)
5784 (list 'keymap markdown-mode-mouse-map
5785 'font-lock-multiline t
5786 'help-echo echo-text))))
5787
5788
5734;;; Menu ====================================================================== 5789;;; Menu ======================================================================
5735 5790
5736(easy-menu-define markdown-mode-menu markdown-mode-map 5791(easy-menu-define markdown-mode-menu markdown-mode-map
@@ -8208,39 +8263,20 @@ Translate filenames using `markdown-filename-translate-function'."
8208 (title-start (match-beginning 7)) 8263 (title-start (match-beginning 7))
8209 (title-end (match-end 7)) 8264 (title-end (match-end 7))
8210 (title (match-string-no-properties 7)) 8265 (title (match-string-no-properties 7))
8211 ;; Markup part 8266 (url-char (markdown--first-displayable markdown-url-compose-char)))
8212 (mp (list 'invisible 'markdown-markup
8213 'rear-nonsticky t
8214 'font-lock-multiline t))
8215 ;; Link part (without face)
8216 (lp (list 'keymap markdown-mode-mouse-map
8217 'font-lock-multiline t
8218 'help-echo (if title (concat title "\n" url) url)))
8219 ;; URL part
8220 (up (list 'keymap markdown-mode-mouse-map
8221 'invisible 'markdown-markup
8222 'font-lock-multiline t))
8223 ;; URL composition character
8224 (url-char (markdown--first-displayable markdown-url-compose-char))
8225 ;; Title part
8226 (tp (list 'invisible 'markdown-markup
8227 'font-lock-multiline t)))
8228 (when markdown-mouse-follow-link
8229 (setq lp (append lp '(mouse-face 'markdown-highlight-face)))
8230 (setq up (append up '(mouse-face 'markdown-highlight-face))))
8231 (dolist (g '(1 2 4 5 8)) 8267 (dolist (g '(1 2 4 5 8))
8232 (when (match-end g) 8268 (when (match-end g)
8233 (add-text-properties (match-beginning g) (match-end g) mp) 8269 (add-text-properties (match-beginning g) (match-end g) markdown--markup-props)
8234 (add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face))) 8270 (add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face)))
8235 ;; Preserve existing faces applied to link part (e.g., inline code) 8271 ;; Preserve existing faces applied to link part (e.g., inline code)
8236 (when link-start 8272 (when link-start
8237 (add-text-properties link-start link-end lp) 8273 (add-text-properties link-start link-end (markdown--link-props url title))
8238 (add-face-text-property link-start link-end 'markdown-link-face)) 8274 (add-face-text-property link-start link-end 'markdown-link-face))
8239 (when url-start 8275 (when url-start
8240 (add-text-properties url-start url-end up) 8276 (add-text-properties url-start url-end (markdown--url-props))
8241 (add-face-text-property url-start url-end 'markdown-url-face)) 8277 (add-face-text-property url-start url-end 'markdown-url-face))
8242 (when title-start 8278 (when title-start
8243 (add-text-properties url-end title-end tp) 8279 (add-text-properties url-end title-end markdown--title-props)
8244 (add-face-text-property url-end title-end 'markdown-link-title-face)) 8280 (add-face-text-property url-end title-end 'markdown-link-title-face))
8245 (when (and markdown-hide-urls url-start) 8281 (when (and markdown-hide-urls url-start)
8246 (compose-region url-start (or title-end url-end) url-char)) 8282 (compose-region url-start (or title-end url-end) url-char))
@@ -8253,11 +8289,7 @@ Translate filenames using `markdown-filename-translate-function'."
8253 (link-end (match-end 3)) 8289 (link-end (match-end 3))
8254 (ref-start (match-beginning 6)) 8290 (ref-start (match-beginning 6))
8255 (ref-end (match-end 6)) 8291 (ref-end (match-end 6))
8256 ;; Markup part 8292 ;; Link properties
8257 (mp (list 'invisible 'markdown-markup
8258 'rear-nonsticky t
8259 'font-lock-multiline t))
8260 ;; Link part
8261 (lp (list 'keymap markdown-mode-mouse-map 8293 (lp (list 'keymap markdown-mode-mouse-map
8262 'font-lock-multiline t 8294 'font-lock-multiline t
8263 'help-echo (lambda (_ __ pos) 8295 'help-echo (lambda (_ __ pos)
@@ -8268,14 +8300,14 @@ Translate filenames using `markdown-filename-translate-function'."
8268 "Undefined reference")))))) 8300 "Undefined reference"))))))
8269 ;; URL composition character 8301 ;; URL composition character
8270 (url-char (markdown--first-displayable markdown-url-compose-char)) 8302 (url-char (markdown--first-displayable markdown-url-compose-char))
8271 ;; Reference part 8303 ;; Reference properties
8272 (rp (list 'invisible 'markdown-markup 8304 (rp (list 'invisible 'markdown-markup
8273 'font-lock-multiline t))) 8305 'font-lock-multiline t)))
8274 (when markdown-mouse-follow-link 8306 (when markdown-mouse-follow-link
8275 (setq lp (append lp '(mouse-face markdown-highlight-face)))) 8307 (setq lp (append lp '(mouse-face markdown-highlight-face))))
8276 (dolist (g '(1 2 4 5 8)) 8308 (dolist (g '(1 2 4 5 8))
8277 (when (match-end g) 8309 (when (match-end g)
8278 (add-text-properties (match-beginning g) (match-end g) mp) 8310 (add-text-properties (match-beginning g) (match-end g) markdown--markup-props)
8279 (add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face))) 8311 (add-face-text-property (match-beginning g) (match-end g) 'markdown-markup-face)))
8280 (when link-start 8312 (when link-start
8281 (add-text-properties link-start link-end lp) 8313 (add-text-properties link-start link-end lp)
@@ -8287,6 +8319,75 @@ Translate filenames using `markdown-filename-translate-function'."
8287 (compose-region ref-start ref-end url-char))) 8319 (compose-region ref-start ref-end url-char)))
8288 t))) 8320 t)))
8289 8321
8322(defun markdown-fontify-wiki-links (last)
8323 "Add text properties to next wiki link from point to LAST."
8324 (when (and markdown-enable-wiki-links
8325 (markdown-match-inline-generic markdown-regex-wiki-link last))
8326 (let* ((begin (match-beginning 1))
8327 (end (match-end 1))
8328 (beg2 (match-beginning 2))
8329 (end2 (match-end 2))
8330 (beg3 (match-beginning 3))
8331 (end3 (match-end 3))
8332 (beg4 (match-beginning 4))
8333 (end4 (match-end 4))
8334 (beg5 (match-beginning 5))
8335 (end5 (match-end 5))
8336 (beg6 (match-beginning 6))
8337 (end6 (match-end 6))
8338 (part1 (match-string-no-properties 3))
8339 (part2 (match-string-no-properties 5))
8340 (aliasp (string-equal (match-string-no-properties 4) "|"))
8341 (file-name (markdown-convert-wiki-link-to-filename (markdown-wiki-link-link)))
8342 (file-missing-p (not (file-exists-p file-name))))
8343 (if (or (markdown-in-comment-p begin)
8344 (markdown-in-comment-p end)
8345 (markdown-inline-code-at-pos-p begin)
8346 (markdown-inline-code-at-pos-p end)
8347 (markdown-code-block-at-pos begin))
8348 (progn (goto-char (min (1+ begin) last))
8349 (when (< (point) last)
8350 (markdown-fontify-wiki-links last)))
8351 ;; Add text properties for hiding markup
8352 (progn
8353 ;; Propertize opening and closing brackets
8354 (add-text-properties beg2 end2 markdown--markup-props)
8355 (add-face-text-property beg2 end2 'markdown-markup-face)
8356 (add-text-properties beg6 end6 markdown--markup-props)
8357 (add-face-text-property beg6 end6 'markdown-markup-face)
8358 (if aliasp
8359 (progn
8360 ;; Propertize pipe separating URL from link text
8361 (add-text-properties beg4 end4 markdown--markup-props)
8362 (add-face-text-property beg4 end4 'markdown-markup-face)
8363 (if markdown-wiki-link-alias-first
8364 (progn
8365 ;; Properties alias portion of link
8366 (add-text-properties beg3 end3 (markdown--link-props part2))
8367 (add-face-text-property beg3 end3 'markdown-link-face)
8368 (add-text-properties beg5 end5 (markdown--url-props))
8369 (add-text-properties beg5 end5 '(invisible markdown-markup))
8370 (add-face-text-property beg5 end5 'markdown-url-face)
8371 (when (and file-missing-p markdown-wiki-link-fontify-missing)
8372 (put-text-property beg3 end3 'face 'markdown-missing-link-face)))
8373 (progn
8374 ;; Properties URL portion of link
8375 (add-text-properties beg3 end3 (markdown--url-props))
8376 (add-text-properties beg3 end3 '(invisible markdown-markup))
8377 (add-face-text-property beg3 end3 'markdown-url-face)
8378 (add-text-properties beg5 end5 (markdown--link-props part1))
8379 (add-face-text-property beg5 end5 'markdown-link-face)
8380 (when (and file-missing-p markdown-wiki-link-fontify-missing)
8381 (put-text-property beg5 end5 'face 'markdown-missing-link-face)))))
8382 (progn
8383 ;; Properties link as link text
8384 (add-text-properties beg3 end3 (markdown--link-props part1))
8385 (add-face-text-property beg3 end3 'markdown-link-face)
8386 (when (and file-missing-p markdown-wiki-link-fontify-missing)
8387 (put-text-property beg3 end3 'face 'markdown-missing-link-face)))))
8388 (set-match-data (list begin end))
8389 t))))
8390
8290(defun markdown-fontify-angle-uris (last) 8391(defun markdown-fontify-angle-uris (last)
8291 "Add text properties to angle URIs from point to LAST." 8392 "Add text properties to angle URIs from point to LAST."
8292 (when (markdown-match-angle-uris last) 8393 (when (markdown-match-angle-uris last)
@@ -8294,15 +8395,11 @@ Translate filenames using `markdown-filename-translate-function'."
8294 (url-end (match-end 2))) 8395 (url-end (match-end 2)))
8295 (unless (or (markdown-in-inline-code-p url-start) 8396 (unless (or (markdown-in-inline-code-p url-start)
8296 (markdown-in-inline-code-p url-end)) 8397 (markdown-in-inline-code-p url-end))
8297 (let* (;; Markup part 8398 (let ((mp (append '(face markdown-markup-face) (cl-copy-list markdown--markup-props)))
8298 (mp (list 'face 'markdown-markup-face 8399 ;; URI part
8299 'invisible 'markdown-markup 8400 (up (list 'keymap markdown-mode-mouse-map
8300 'rear-nonsticky t 8401 'face 'markdown-plain-url-face
8301 'font-lock-multiline t)) 8402 'font-lock-multiline t)))
8302 ;; URI part
8303 (up (list 'keymap markdown-mode-mouse-map
8304 'face 'markdown-plain-url-face
8305 'font-lock-multiline t)))
8306 (when markdown-mouse-follow-link 8403 (when markdown-mouse-follow-link
8307 (setq up (append up '(mouse-face markdown-highlight-face)))) 8404 (setq up (append up '(mouse-face markdown-highlight-face))))
8308 (dolist (g '(1 3)) 8405 (dolist (g '(1 3))
@@ -8372,6 +8469,11 @@ The location of the alias component depends on the value of
8372 (or (match-string-no-properties 5) (match-string-no-properties 3)))) 8469 (or (match-string-no-properties 5) (match-string-no-properties 3))))
8373 8470
8374(defun markdown--wiki-link-search-types () 8471(defun markdown--wiki-link-search-types ()
8472 "Return a list of the currently selected search types.
8473
8474Due to deprecated variables, as of markdown-mode version 2.5, the return value
8475of this function is the same as the value of the variable
8476`markdown-wiki-link-search-type'."
8375 (let ((ret (and markdown-wiki-link-search-type 8477 (let ((ret (and markdown-wiki-link-search-type
8376 (cl-copy-list markdown-wiki-link-search-type)))) 8478 (cl-copy-list markdown-wiki-link-search-type))))
8377 (when (and markdown-wiki-link-search-subdirectories 8479 (when (and markdown-wiki-link-search-subdirectories
@@ -8383,6 +8485,7 @@ The location of the alias component depends on the value of
8383 ret)) 8485 ret))
8384 8486
8385(defun markdown--project-root () 8487(defun markdown--project-root ()
8488 "Try various approaches to find the project root."
8386 (or (cl-loop for dir in '(".git" ".hg" ".svn") 8489 (or (cl-loop for dir in '(".git" ".hg" ".svn")
8387 when (locate-dominating-file default-directory dir) 8490 when (locate-dominating-file default-directory dir)
8388 return it) 8491 return it)
@@ -8397,12 +8500,9 @@ The location of the alias component depends on the value of
8397(defun markdown-convert-wiki-link-to-filename (name) 8500(defun markdown-convert-wiki-link-to-filename (name)
8398 "Generate a filename from the wiki link NAME. 8501 "Generate a filename from the wiki link NAME.
8399Spaces in NAME are replaced with `markdown-link-space-sub-char'. 8502Spaces in NAME are replaced with `markdown-link-space-sub-char'.
8503Search depth is determined by `markdown-wiki-link-search-type'.
8400When in `gfm-mode', follow GitHub's conventions where [[Test Test]] 8504When in `gfm-mode', follow GitHub's conventions where [[Test Test]]
8401and [[test test]] both map to Test-test.ext. Look in the current 8505and [[test test]] both map to Test-test.ext."
8402directory first, then in subdirectories if
8403`markdown-wiki-link-search-subdirectories' is non-nil, and then
8404in parent directories if
8405`markdown-wiki-link-search-parent-directories' is non-nil."
8406 (save-match-data 8506 (save-match-data
8407 ;; This function must not overwrite match data(PR #590) 8507 ;; This function must not overwrite match data(PR #590)
8408 (let* ((basename (replace-regexp-in-string 8508 (let* ((basename (replace-regexp-in-string
@@ -8493,11 +8593,12 @@ and highlight accordingly."
8493 (file-name 8593 (file-name
8494 (markdown-convert-wiki-link-to-filename 8594 (markdown-convert-wiki-link-to-filename
8495 (markdown-wiki-link-link)))) 8595 (markdown-wiki-link-link))))
8496 (if (condition-case nil (file-exists-p file-name) (error nil)) 8596 (with-no-warnings
8597 (if (condition-case nil (file-exists-p file-name) (error nil))
8598 (markdown-highlight-wiki-link
8599 highlight-beginning highlight-end 'markdown-link-face)
8497 (markdown-highlight-wiki-link 8600 (markdown-highlight-wiki-link
8498 highlight-beginning highlight-end 'markdown-link-face) 8601 highlight-beginning highlight-end 'markdown-missing-link-face))))))))
8499 (markdown-highlight-wiki-link
8500 highlight-beginning highlight-end 'markdown-missing-link-face)))))))
8501 8602
8502(defun markdown-extend-changed-region (from to) 8603(defun markdown-extend-changed-region (from to)
8503 "Extend region given by FROM and TO so that we can fontify all links. 8604 "Extend region given by FROM and TO so that we can fontify all links.
@@ -8533,7 +8634,8 @@ newline after."
8533 ;; Extend the region to fontify so that it starts 8634 ;; Extend the region to fontify so that it starts
8534 ;; and ends at safe places. 8635 ;; and ends at safe places.
8535 (cl-multiple-value-bind (new-from new-to) 8636 (cl-multiple-value-bind (new-from new-to)
8536 (markdown-extend-changed-region from to) 8637 (with-no-warnings
8638 (markdown-extend-changed-region from to))
8537 (goto-char new-from) 8639 (goto-char new-from)
8538 ;; Only refontify when the range contains text with a 8640 ;; Only refontify when the range contains text with a
8539 ;; wiki link face or if the wiki link regexp matches. 8641 ;; wiki link face or if the wiki link regexp matches.
@@ -8542,10 +8644,11 @@ newline after."
8542 '(markdown-link-face markdown-missing-link-face)) 8644 '(markdown-link-face markdown-missing-link-face))
8543 (re-search-forward 8645 (re-search-forward
8544 markdown-regex-wiki-link new-to t)) 8646 markdown-regex-wiki-link new-to t))
8545 ;; Unfontify existing fontification (start from scratch) 8647 (with-no-warnings
8546 (markdown-unfontify-region-wiki-links new-from new-to) 8648 ;; Unfontify existing fontification (start from scratch)
8547 ;; Now do the fontification. 8649 (markdown-unfontify-region-wiki-links new-from new-to)
8548 (markdown-fontify-region-wiki-links new-from new-to)))))) 8650 ;; Now do the fontification.
8651 (markdown-fontify-region-wiki-links new-from new-to)))))))
8549 (cursor-intangible-mode -1) 8652 (cursor-intangible-mode -1)
8550 (and (not modified) 8653 (and (not modified)
8551 (buffer-modified-p) 8654 (buffer-modified-p)
@@ -8554,12 +8657,14 @@ newline after."
8554(defun markdown-check-change-for-wiki-link-after-change (from to _) 8657(defun markdown-check-change-for-wiki-link-after-change (from to _)
8555 "Check region between FROM and TO for wiki links and re-fontify as needed. 8658 "Check region between FROM and TO for wiki links and re-fontify as needed.
8556Designed to be used with the `after-change-functions' hook." 8659Designed to be used with the `after-change-functions' hook."
8557 (markdown-check-change-for-wiki-link from to)) 8660 (with-no-warnings
8661 (markdown-check-change-for-wiki-link from to)))
8558 8662
8559(defun markdown-fontify-buffer-wiki-links () 8663(defun markdown-fontify-buffer-wiki-links ()
8560 "Refontify all wiki links in the buffer." 8664 "Refontify all wiki links in the buffer."
8561 (interactive) 8665 (interactive)
8562 (markdown-check-change-for-wiki-link (point-min) (point-max))) 8666 (with-no-warnings
8667 (markdown-check-change-for-wiki-link (point-min) (point-max))))
8563 8668
8564(defun markdown-toggle-wiki-links (&optional arg) 8669(defun markdown-toggle-wiki-links (&optional arg)
8565 "Toggle support for wiki links. 8670 "Toggle support for wiki links.
@@ -8571,33 +8676,36 @@ and disable it otherwise."
8571 (not markdown-enable-wiki-links) 8676 (not markdown-enable-wiki-links)
8572 (> (prefix-numeric-value arg) 0))) 8677 (> (prefix-numeric-value arg) 0)))
8573 (when (called-interactively-p 'interactive) 8678 (when (called-interactively-p 'interactive)
8574 (message "markdown-mode wiki link support %s" (if markdown-enable-wiki-links "enabled" "disabled"))) 8679 (message "markdown-mode wiki link support %s"
8680 (if markdown-enable-wiki-links "enabled" "disabled")))
8575 (markdown-reload-extensions)) 8681 (markdown-reload-extensions))
8576 8682
8577(defun markdown-setup-wiki-link-hooks () 8683(defun markdown-setup-wiki-link-hooks ()
8578 "Add or remove hooks for fontifying wiki links. 8684 "Add or remove hooks for fontifying wiki links.
8579These are only enabled when `markdown-wiki-link-fontify-missing' is non-nil." 8685These are only enabled when `markdown-wiki-link-fontify-missing' is non-nil."
8580 ;; Anytime text changes make sure it gets fontified correctly 8686 ;; Anytime text changes make sure it gets fontified correctly
8581 (if (and markdown-enable-wiki-links 8687 (with-no-warnings
8582 markdown-wiki-link-fontify-missing) 8688 (if (and markdown-enable-wiki-links
8583 (add-hook 'after-change-functions 8689 markdown-wiki-link-fontify-missing)
8584 #'markdown-check-change-for-wiki-link-after-change t t) 8690 (add-hook 'after-change-functions
8585 (remove-hook 'after-change-functions 8691 #'markdown-check-change-for-wiki-link-after-change t t)
8586 #'markdown-check-change-for-wiki-link-after-change t)) 8692 (remove-hook 'after-change-functions
8587 ;; If we left the buffer there is a really good chance we were 8693 #'markdown-check-change-for-wiki-link-after-change t))
8588 ;; creating one of the wiki link documents. Make sure we get 8694 ;; If we left the buffer there is a really good chance we were
8589 ;; refontified when we come back. 8695 ;; creating one of the wiki link documents. Make sure we get
8590 (if (and markdown-enable-wiki-links 8696 ;; refontified when we come back.
8591 markdown-wiki-link-fontify-missing) 8697 (if (and markdown-enable-wiki-links
8592 (progn 8698 markdown-wiki-link-fontify-missing)
8593 (add-hook 'window-configuration-change-hook 8699 (progn
8594 #'markdown-fontify-buffer-wiki-links t t) 8700 (add-hook 'window-configuration-change-hook
8595 (markdown-fontify-buffer-wiki-links)) 8701 #'markdown-fontify-buffer-wiki-links t t)
8596 (remove-hook 'window-configuration-change-hook 8702 (markdown-fontify-buffer-wiki-links))
8597 #'markdown-fontify-buffer-wiki-links t) 8703 (remove-hook 'window-configuration-change-hook
8598 (markdown-unfontify-region-wiki-links (point-min) (point-max)))) 8704 #'markdown-fontify-buffer-wiki-links t)
8705 (with-no-warnings
8706 (markdown-unfontify-region-wiki-links (point-min) (point-max))))) )
8707
8599 8708
8600
8601;;; Following & Doing ========================================================= 8709;;; Following & Doing =========================================================
8602 8710
8603(defun markdown-follow-thing-at-point (arg) 8711(defun markdown-follow-thing-at-point (arg)
@@ -8784,9 +8892,7 @@ or span."
8784 (interactive) 8892 (interactive)
8785 (when (derived-mode-p 'markdown-mode) 8893 (when (derived-mode-p 'markdown-mode)
8786 ;; Refontify buffer 8894 ;; Refontify buffer
8787 (font-lock-flush) 8895 (font-lock-flush)))
8788 ;; Add or remove hooks related to extensions
8789 (markdown-setup-wiki-link-hooks)))
8790 8896
8791(defun markdown-handle-local-variables () 8897(defun markdown-handle-local-variables ()
8792 "Run in `hack-local-variables-hook' to update font lock rules. 8898 "Run in `hack-local-variables-hook' to update font lock rules.
@@ -10090,6 +10196,19 @@ rows and columns and the column alignment."
10090 (propertize link 'face 'markdown-reference-face) 10196 (propertize link 'face 'markdown-reference-face)
10091 (propertize "]" 'face 'markdown-markup-face)) 10197 (propertize "]" 'face 'markdown-markup-face))
10092 (propertize link 'face 'markdown-url-face))))) 10198 (propertize link 'face 'markdown-url-face)))))
10199 ;; Hidden URL for wiki links
10200 ((and (and markdown-enable-wiki-links
10201 (thing-at-point-looking-at markdown-regex-wiki-link))
10202 (or markdown-hide-urls markdown-hide-markup))
10203 (let* ((aliasp (string-equal (match-string-no-properties 4) "|"))
10204 (part1 (match-string-no-properties 3))
10205 (part2 (match-string-no-properties 5))
10206 (link (if (and aliasp markdown-wiki-link-alias-first) part2 part1))
10207 (edit-keys (markdown--substitute-command-keys
10208 "\\[markdown-insert-wiki-link]"))
10209 (edit-str (propertize edit-keys 'face 'font-lock-constant-face)))
10210 (format "Hidden URL (%s to edit): %s"
10211 edit-str (propertize link 'face 'markdown-reference-face))))
10093 ;; Hidden language name for fenced code blocks 10212 ;; Hidden language name for fenced code blocks
10094 ((and (markdown-code-block-at-point-p) 10213 ((and (markdown-code-block-at-point-p)
10095 (not (get-text-property (point) 'markdown-pre)) 10214 (not (get-text-property (point) 'markdown-pre))
@@ -10224,8 +10343,6 @@ rows and columns and the column alignment."
10224 (if markdown-hide-markup 10343 (if markdown-hide-markup
10225 (add-to-invisibility-spec 'markdown-markup) 10344 (add-to-invisibility-spec 'markdown-markup)
10226 (remove-from-invisibility-spec 'markdown-markup)) 10345 (remove-from-invisibility-spec 'markdown-markup))
10227 ;; Wiki links
10228 (markdown-setup-wiki-link-hooks)
10229 ;; Math mode 10346 ;; Math mode
10230 (when markdown-enable-math (markdown-toggle-math t)) 10347 (when markdown-enable-math (markdown-toggle-math t))
10231 ;; Add a buffer-local hook to reload after file-local variables are read 10348 ;; Add a buffer-local hook to reload after file-local variables are read
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 602e74e..806f2bc 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -5,7 +5,7 @@
5;; João Távora <joaotavora@gmail.com>, 5;; João Távora <joaotavora@gmail.com>,
6;; Noam Postavsky <npostavs@gmail.com> 6;; Noam Postavsky <npostavs@gmail.com>
7;; Maintainer: Noam Postavsky <npostavs@gmail.com> 7;; Maintainer: Noam Postavsky <npostavs@gmail.com>
8;; Version: 0.14.1 8;; Version: 0.14.2
9;; X-URL: http://github.com/joaotavora/yasnippet 9;; X-URL: http://github.com/joaotavora/yasnippet
10;; Keywords: convenience, emulation 10;; Keywords: convenience, emulation
11;; URL: http://github.com/joaotavora/yasnippet 11;; URL: http://github.com/joaotavora/yasnippet
@@ -588,8 +588,6 @@ can be useful."
588 588
589;;; Internal variables 589;;; Internal variables
590 590
591(defconst yas--version "0.14.0")
592
593(defvar yas--menu-table (make-hash-table) 591(defvar yas--menu-table (make-hash-table)
594 "A hash table of MAJOR-MODE symbols to menu keymaps.") 592 "A hash table of MAJOR-MODE symbols to menu keymaps.")
595 593
@@ -891,18 +889,10 @@ which decides on the snippet to expand.")
891 889
892;;;###autoload 890;;;###autoload
893(define-minor-mode yas-minor-mode 891(define-minor-mode yas-minor-mode
894 "Toggle YASnippet mode. 892 "YASnippet minor mode.
895 893
896When YASnippet mode is enabled, `yas-expand', normally bound to 894When YASnippet mode is enabled, `yas-expand', normally bound to
897the TAB key, expands snippets of code depending on the major 895the TAB key, expands snippets of code depending on the major mode."
898mode.
899
900With no argument, this command toggles the mode.
901positive prefix argument turns on the mode.
902Negative prefix argument turns off the mode.
903
904Key bindings:
905\\{yas-minor-mode-map}"
906 :lighter " yas" ;; The indicator for the mode line. 896 :lighter " yas" ;; The indicator for the mode line.
907 (cond ((and yas-minor-mode (featurep 'yasnippet)) 897 (cond ((and yas-minor-mode (featurep 'yasnippet))
908 ;; Install the direct keymaps in `emulation-mode-map-alists' 898 ;; Install the direct keymaps in `emulation-mode-map-alists'
@@ -1463,7 +1453,7 @@ Returns (TEMPLATES START END). This function respects
1463(defun yas--remove-misc-free-from-undo (old-undo-list) 1453(defun yas--remove-misc-free-from-undo (old-undo-list)
1464 "Tries to work around Emacs Bug#30931. 1454 "Tries to work around Emacs Bug#30931.
1465Helper function for `yas--save-restriction-and-widen'." 1455Helper function for `yas--save-restriction-and-widen'."
1466 ;; If Bug#30931 is unfixed, we get (#<Lisp_Misc_Free> . INTEGER) 1456 ;; If Bug#30931 is unfixed (Emacs<26.2), we get (#<Lisp_Misc_Free> . INTEGER)
1467 ;; entries in the undo list. If we call `type-of' on the 1457 ;; entries in the undo list. If we call `type-of' on the
1468 ;; Lisp_Misc_Free object then Emacs aborts, so try to find it by 1458 ;; Lisp_Misc_Free object then Emacs aborts, so try to find it by
1469 ;; checking that its type is none of the expected ones. 1459 ;; checking that its type is none of the expected ones.
@@ -1487,15 +1477,16 @@ Helper function for `yas--save-restriction-and-widen'."
1487 1477
1488(defmacro yas--save-restriction-and-widen (&rest body) 1478(defmacro yas--save-restriction-and-widen (&rest body)
1489 "Equivalent to (save-restriction (widen) BODY). 1479 "Equivalent to (save-restriction (widen) BODY).
1490Also tries to work around Emacs Bug#30931." 1480Also tries to work around Emacs Bug#30931, fixed in Emacs-26.2."
1491 (declare (debug (body)) (indent 0)) 1481 (declare (debug (body)) (indent 0))
1492 ;; Disable garbage collection, since it could cause an abort. 1482 (let ((main `(save-restriction (widen) ,@body)))
1493 `(let ((gc-cons-threshold most-positive-fixnum) 1483 (if (< emacs-major-version 27)
1494 (old-undo-list buffer-undo-list)) 1484 ;; Disable garbage collection, since it could cause an abort.
1495 (prog1 (save-restriction 1485 `(let ((gc-cons-threshold most-positive-fixnum)
1496 (widen) 1486 (old-undo-list buffer-undo-list))
1497 ,@body) 1487 (prog1 ,main
1498 (yas--remove-misc-free-from-undo old-undo-list)))) 1488 (yas--remove-misc-free-from-undo old-undo-list)))
1489 main)))
1499 1490
1500(defun yas--eval-for-string (form) 1491(defun yas--eval-for-string (form)
1501 "Evaluate FORM and convert the result to string." 1492 "Evaluate FORM and convert the result to string."
@@ -1679,8 +1670,9 @@ Here's a list of currently recognized directives:
1679 (directory-files directory t))) 1670 (directory-files directory t)))
1680 1671
1681(defun yas--make-menu-binding (template) 1672(defun yas--make-menu-binding (template)
1682 (let ((mode (yas--table-mode (yas--template-table template)))) 1673 (let ((mode (yas--table-mode (yas--template-table template)))
1683 `(lambda () (interactive) (yas--expand-or-visit-from-menu ',mode ,(yas--template-uuid template))))) 1674 (uuid (yas--template-uuid template)))
1675 (lambda () (interactive) (yas--expand-or-visit-from-menu mode uuid))))
1684 1676
1685(defun yas--expand-or-visit-from-menu (mode uuid) 1677(defun yas--expand-or-visit-from-menu (mode uuid)
1686 (let* ((table (yas--table-get-create mode)) 1678 (let* ((table (yas--table-get-create mode))
@@ -2127,27 +2119,23 @@ This works by stubbing a few functions, then calling
2127(defun yas-about () 2119(defun yas-about ()
2128 (interactive) 2120 (interactive)
2129 (message "yasnippet (version %s) -- pluskid/joaotavora/npostavs" 2121 (message "yasnippet (version %s) -- pluskid/joaotavora/npostavs"
2130 (or (ignore-errors (car (let ((default-directory yas--loaddir)) 2122 (or (eval-when-compile
2131 (process-lines "git" "describe"
2132 "--tags" "--dirty"))))
2133 (eval-when-compile
2134 (and (fboundp 'package-get-version) 2123 (and (fboundp 'package-get-version)
2135 (package-get-version))) 2124 (package-get-version)))
2136 (when (and (featurep 'package) 2125 (when (and (boundp 'package-alist)
2137 (fboundp 'package-desc-version) 2126 (fboundp 'package-desc-version)
2138 (fboundp 'package-version-join)) 2127 (fboundp 'package-version-join))
2139 (defvar package-alist)
2140 (ignore-errors 2128 (ignore-errors
2141 (let* ((yas-pkg (cdr (assq 'yasnippet package-alist))) 2129 (let* ((yas-pkg (cdr (assq 'yasnippet package-alist))))
2142 (version (package-version-join 2130 (when yas-pkg
2143 (package-desc-version (car yas-pkg))))) 2131 (package-version-join
2144 ;; Special case for MELPA's bogus version numbers. 2132 (package-desc-version (car yas-pkg)))))))
2145 (if (string-match "\\`20..[01][0-9][0-3][0-9][.][0-9]\\{3,4\\}\\'" 2133 ;; The Git description can be misleading, for lack of
2146 version) 2134 ;; recent tags, so we prefer package version info.
2147 (concat yas--version "-snapshot" version) 2135 (ignore-errors (car (let ((default-directory yas--loaddir))
2148 version)))) 2136 (process-lines "git" "describe"
2149 yas--version))) 2137 "--tags" "--dirty"))))
2150 2138 "unknown")))
2151 2139
2152;;; Apropos snippet menu: 2140;;; Apropos snippet menu:
2153;; 2141;;
@@ -4133,7 +4121,7 @@ Returns the newly created snippet."
4133 (unwind-protect 4121 (unwind-protect
4134 (let ((buffer-undo-list t)) 4122 (let ((buffer-undo-list t))
4135 (goto-char begin) 4123 (goto-char begin)
4136 (if (> emacs-major-version 29) 4124 (if (< emacs-major-version 27)
4137 ;; Don't use the workaround for CC-mode's cache, 4125 ;; Don't use the workaround for CC-mode's cache,
4138 ;; since it was presumably a bug in CC-mode, so either 4126 ;; since it was presumably a bug in CC-mode, so either
4139 ;; it's fixed already, or it should get fixed. 4127 ;; it's fixed already, or it should get fixed.
@@ -4161,6 +4149,7 @@ Returns the newly created snippet."
4161 (run-hook-with-args 'after-change-functions 4149 (run-hook-with-args 'after-change-functions
4162 (point-min) (point-max) 4150 (point-min) (point-max)
4163 (- end begin)))) 4151 (- end begin))))
4152 ;; FIXME: Use `undo-amalgamate-change-group'?
4164 (when (listp buffer-undo-list) 4153 (when (listp buffer-undo-list)
4165 (push (cons (point-min) (point-max)) 4154 (push (cons (point-min) (point-max))
4166 buffer-undo-list))) 4155 buffer-undo-list)))
@@ -5056,7 +5045,7 @@ object satisfying `yas--field-p' to restrict the expansion to.")))
5056(define-button-type 'help-snippet-def 5045(define-button-type 'help-snippet-def
5057 :supertype 'help-xref 5046 :supertype 'help-xref
5058 'help-function (lambda (template) (yas--visit-snippet-file-1 template)) 5047 'help-function (lambda (template) (yas--visit-snippet-file-1 template))
5059 'help-echo (purecopy "mouse-2, RET: find snippets's definition")) 5048 'help-echo "mouse-2, RET: find snippets's definition")
5060 5049
5061(defun yas--snippet-description-finish-runonce () 5050(defun yas--snippet-description-finish-runonce ()
5062 "Final adjustments for the help buffer when snippets are concerned." 5051 "Final adjustments for the help buffer when snippets are concerned."