diff options
| author | Simeon Simeonov | 2025-02-28 18:30:17 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2025-02-28 18:30:17 +0100 |
| commit | bcd993046ffaa3390bcf3252db8ba69d4610191c (patch) | |
| tree | 2f7fcfe1ed46f224119bc97346d6036c0504766b /.emacs.d/lisp | |
| parent | f6a91e549fe34f047acdb03e806e0f7dce9ffce1 (diff) | |
Add snippets/rust-mode and upgrade markdown-mode
Diffstat (limited to '.emacs.d/lisp')
| -rw-r--r-- | .emacs.d/lisp/markdown-mode.el | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index f99897d..a914eb3 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el | |||
| @@ -6,8 +6,8 @@ | |||
| 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.7-alpha | 9 | ;; Version: 2.8-alpha |
| 10 | ;; Package-Requires: ((emacs "27.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/ |
| 13 | 13 | ||
| @@ -62,7 +62,7 @@ | |||
| 62 | 62 | ||
| 63 | ;;; Constants ================================================================= | 63 | ;;; Constants ================================================================= |
| 64 | 64 | ||
| 65 | (defconst markdown-mode-version "2.7-alpha" | 65 | (defconst markdown-mode-version "2.8-alpha" |
| 66 | "Markdown mode version number.") | 66 | "Markdown mode version number.") |
| 67 | 67 | ||
| 68 | (defconst markdown-output-buffer-name "*markdown-output*" | 68 | (defconst markdown-output-buffer-name "*markdown-output*" |
| @@ -1177,6 +1177,10 @@ escape character (see `markdown-match-escape').") | |||
| 1177 | If POS is not given, use point instead." | 1177 | If POS is not given, use point instead." |
| 1178 | (get-text-property (or pos (point)) 'markdown-comment)) | 1178 | (get-text-property (or pos (point)) 'markdown-comment)) |
| 1179 | 1179 | ||
| 1180 | (defsubst markdown-in-inline-code-p (pos) | ||
| 1181 | "Return non-nil if POS is in inline code." | ||
| 1182 | (equal (get-text-property pos 'face) '(markdown-inline-code-face))) | ||
| 1183 | |||
| 1180 | (defun markdown--face-p (pos faces) | 1184 | (defun markdown--face-p (pos faces) |
| 1181 | "Return non-nil if face of POS contain FACES." | 1185 | "Return non-nil if face of POS contain FACES." |
| 1182 | (let ((face-prop (get-text-property pos 'face))) | 1186 | (let ((face-prop (get-text-property pos 'face))) |
| @@ -8195,19 +8199,20 @@ Translate filenames using `markdown-filename-translate-function'." | |||
| 8195 | 'font-lock-multiline t)) | 8199 | 'font-lock-multiline t)) |
| 8196 | ;; Link part (without face) | 8200 | ;; Link part (without face) |
| 8197 | (lp (list 'keymap markdown-mode-mouse-map | 8201 | (lp (list 'keymap markdown-mode-mouse-map |
| 8198 | 'mouse-face 'markdown-highlight-face | ||
| 8199 | 'font-lock-multiline t | 8202 | 'font-lock-multiline t |
| 8200 | 'help-echo (if title (concat title "\n" url) url))) | 8203 | 'help-echo (if title (concat title "\n" url) url))) |
| 8201 | ;; URL part | 8204 | ;; URL part |
| 8202 | (up (list 'keymap markdown-mode-mouse-map | 8205 | (up (list 'keymap markdown-mode-mouse-map |
| 8203 | 'invisible 'markdown-markup | 8206 | 'invisible 'markdown-markup |
| 8204 | 'mouse-face 'markdown-highlight-face | ||
| 8205 | 'font-lock-multiline t)) | 8207 | 'font-lock-multiline t)) |
| 8206 | ;; URL composition character | 8208 | ;; URL composition character |
| 8207 | (url-char (markdown--first-displayable markdown-url-compose-char)) | 8209 | (url-char (markdown--first-displayable markdown-url-compose-char)) |
| 8208 | ;; Title part | 8210 | ;; Title part |
| 8209 | (tp (list 'invisible 'markdown-markup | 8211 | (tp (list 'invisible 'markdown-markup |
| 8210 | 'font-lock-multiline t))) | 8212 | 'font-lock-multiline t))) |
| 8213 | (when markdown-mouse-follow-link | ||
| 8214 | (setq lp (append lp '(mouse-face 'markdown-highlight-face))) | ||
| 8215 | (setq up (append up '(mouse-face 'markdown-highlight-face)))) | ||
| 8211 | (dolist (g '(1 2 4 5 8)) | 8216 | (dolist (g '(1 2 4 5 8)) |
| 8212 | (when (match-end g) | 8217 | (when (match-end g) |
| 8213 | (add-text-properties (match-beginning g) (match-end g) mp) | 8218 | (add-text-properties (match-beginning g) (match-end g) mp) |
| @@ -8239,7 +8244,6 @@ Translate filenames using `markdown-filename-translate-function'." | |||
| 8239 | 'font-lock-multiline t)) | 8244 | 'font-lock-multiline t)) |
| 8240 | ;; Link part | 8245 | ;; Link part |
| 8241 | (lp (list 'keymap markdown-mode-mouse-map | 8246 | (lp (list 'keymap markdown-mode-mouse-map |
| 8242 | 'mouse-face 'markdown-highlight-face | ||
| 8243 | 'font-lock-multiline t | 8247 | 'font-lock-multiline t |
| 8244 | 'help-echo (lambda (_ __ pos) | 8248 | 'help-echo (lambda (_ __ pos) |
| 8245 | (save-match-data | 8249 | (save-match-data |
| @@ -8252,6 +8256,8 @@ Translate filenames using `markdown-filename-translate-function'." | |||
| 8252 | ;; Reference part | 8256 | ;; Reference part |
| 8253 | (rp (list 'invisible 'markdown-markup | 8257 | (rp (list 'invisible 'markdown-markup |
| 8254 | 'font-lock-multiline t))) | 8258 | 'font-lock-multiline t))) |
| 8259 | (when markdown-mouse-follow-link | ||
| 8260 | (setq lp (append lp '(mouse-face markdown-highlight-face)))) | ||
| 8255 | (dolist (g '(1 2 4 5 8)) | 8261 | (dolist (g '(1 2 4 5 8)) |
| 8256 | (when (match-end g) | 8262 | (when (match-end g) |
| 8257 | (add-text-properties (match-beginning g) (match-end g) mp) | 8263 | (add-text-properties (match-beginning g) (match-end g) mp) |
| @@ -8269,22 +8275,25 @@ Translate filenames using `markdown-filename-translate-function'." | |||
| 8269 | (defun markdown-fontify-angle-uris (last) | 8275 | (defun markdown-fontify-angle-uris (last) |
| 8270 | "Add text properties to angle URIs from point to LAST." | 8276 | "Add text properties to angle URIs from point to LAST." |
| 8271 | (when (markdown-match-angle-uris last) | 8277 | (when (markdown-match-angle-uris last) |
| 8272 | (let* ((url-start (match-beginning 2)) | 8278 | (let ((url-start (match-beginning 2)) |
| 8273 | (url-end (match-end 2)) | 8279 | (url-end (match-end 2))) |
| 8274 | ;; Markup part | 8280 | (unless (or (markdown-in-inline-code-p url-start) |
| 8275 | (mp (list 'face 'markdown-markup-face | 8281 | (markdown-in-inline-code-p url-end)) |
| 8276 | 'invisible 'markdown-markup | 8282 | (let* (;; Markup part |
| 8277 | 'rear-nonsticky t | 8283 | (mp (list 'face 'markdown-markup-face |
| 8278 | 'font-lock-multiline t)) | 8284 | 'invisible 'markdown-markup |
| 8279 | ;; URI part | 8285 | 'rear-nonsticky t |
| 8280 | (up (list 'keymap markdown-mode-mouse-map | 8286 | 'font-lock-multiline t)) |
| 8281 | 'face 'markdown-plain-url-face | 8287 | ;; URI part |
| 8282 | 'mouse-face 'markdown-highlight-face | 8288 | (up (list 'keymap markdown-mode-mouse-map |
| 8283 | 'font-lock-multiline t))) | 8289 | 'face 'markdown-plain-url-face |
| 8284 | (dolist (g '(1 3)) | 8290 | 'font-lock-multiline t))) |
| 8285 | (add-text-properties (match-beginning g) (match-end g) mp)) | 8291 | (when markdown-mouse-follow-link |
| 8286 | (add-text-properties url-start url-end up) | 8292 | (setq up (append up '(mouse-face markdown-highlight-face)))) |
| 8287 | t))) | 8293 | (dolist (g '(1 3)) |
| 8294 | (add-text-properties (match-beginning g) (match-end g) mp)) | ||
| 8295 | (add-text-properties url-start url-end up) | ||
| 8296 | t))))) | ||
| 8288 | 8297 | ||
| 8289 | (defun markdown-fontify-plain-uris (last) | 8298 | (defun markdown-fontify-plain-uris (last) |
| 8290 | "Add text properties to plain URLs from point to LAST." | 8299 | "Add text properties to plain URLs from point to LAST." |
| @@ -8293,9 +8302,10 @@ Translate filenames using `markdown-filename-translate-function'." | |||
| 8293 | (end (match-end 0)) | 8302 | (end (match-end 0)) |
| 8294 | (props (list 'keymap markdown-mode-mouse-map | 8303 | (props (list 'keymap markdown-mode-mouse-map |
| 8295 | 'face 'markdown-plain-url-face | 8304 | 'face 'markdown-plain-url-face |
| 8296 | 'mouse-face 'markdown-highlight-face | ||
| 8297 | 'rear-nonsticky t | 8305 | 'rear-nonsticky t |
| 8298 | 'font-lock-multiline t))) | 8306 | 'font-lock-multiline t))) |
| 8307 | (when markdown-mouse-follow-link | ||
| 8308 | (setq props (append props '(mouse-face markdown-highlight-face)))) | ||
| 8299 | (add-text-properties start end props) | 8309 | (add-text-properties start end props) |
| 8300 | t))) | 8310 | t))) |
| 8301 | 8311 | ||
| @@ -10122,6 +10132,15 @@ rows and columns and the column alignment." | |||
| 10122 | (markdown-insert-inline-image link-text file) | 10132 | (markdown-insert-inline-image link-text file) |
| 10123 | (markdown-insert-inline-link link-text file)))) | 10133 | (markdown-insert-inline-link link-text file)))) |
| 10124 | 10134 | ||
| 10135 | (defun markdown--dnd-multi-local-file-handler (urls action) | ||
| 10136 | (let ((multile-urls-p (> (length urls) 1))) | ||
| 10137 | (dolist (url urls) | ||
| 10138 | (markdown--dnd-local-file-handler url action) | ||
| 10139 | (when multile-urls-p | ||
| 10140 | (insert " "))))) | ||
| 10141 | |||
| 10142 | (put 'markdown--dnd-multi-local-file-handler 'dnd-multiple-handler t) | ||
| 10143 | |||
| 10125 | 10144 | ||
| 10126 | ;;; Mode Definition ========================================================== | 10145 | ;;; Mode Definition ========================================================== |
| 10127 | 10146 | ||
| @@ -10251,8 +10270,14 @@ rows and columns and the column alignment." | |||
| 10251 | #'markdown--inhibit-electric-quote nil :local) | 10270 | #'markdown--inhibit-electric-quote nil :local) |
| 10252 | 10271 | ||
| 10253 | ;; drag and drop handler | 10272 | ;; drag and drop handler |
| 10254 | (setq-local dnd-protocol-alist (cons '("^file:///" . markdown--dnd-local-file-handler) | 10273 | (let ((dnd-handler (if (>= emacs-major-version 30) |
| 10255 | dnd-protocol-alist)) | 10274 | #'markdown--dnd-multi-local-file-handler |
| 10275 | #'markdown--dnd-local-file-handler))) | ||
| 10276 | (setq-local dnd-protocol-alist (append | ||
| 10277 | (list (cons "^file:///" dnd-handler) | ||
| 10278 | (cons "^file:/[^/]" dnd-handler) | ||
| 10279 | (cons "^file:[^/]" dnd-handler)) | ||
| 10280 | dnd-protocol-alist))) | ||
| 10256 | 10281 | ||
| 10257 | ;; media handler | 10282 | ;; media handler |
| 10258 | (when (version< "29" emacs-version) | 10283 | (when (version< "29" emacs-version) |
