summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2023-09-17 01:19:17 +0200
committerSimeon Simeonov2023-09-17 01:19:17 +0200
commit0293defdea75407b6e11b3ebef3bc0d49fac9a58 (patch)
tree4ad1a562bb43a0cd3ef28f06474c4cfb0672433c
parentbb7d0abc12e60aa52c84e36b9fd3200d7f861f8b (diff)
Upgrade markdown-mode and rust-utils
-rw-r--r--.emacs.d/lisp/markdown-mode.el7
-rw-r--r--.emacs.d/lisp/rust-utils.el97
2 files changed, 68 insertions, 36 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el
index 4bb1a57..cd066a8 100644
--- a/.emacs.d/lisp/markdown-mode.el
+++ b/.emacs.d/lisp/markdown-mode.el
@@ -1,12 +1,12 @@
1;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*- 1;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2007-2022 Jason R. Blevins and markdown-mode 3;; Copyright (C) 2007-2023 Jason R. Blevins and markdown-mode
4;; contributors (see the commit log for details). 4;; contributors (see the commit log for details).
5 5
6;; Author: Jason R. Blevins <jblevins@xbeta.org> 6;; Author: Jason R. Blevins <jblevins@xbeta.org>
7;; Maintainer: Jason R. Blevins <jblevins@xbeta.org> 7;; Maintainer: Jason R. Blevins <jblevins@xbeta.org>
8;; Created: May 24, 2007 8;; Created: May 24, 2007
9;; Version: 2.6-alpha 9;; Version: 2.7-alpha
10;; Package-Requires: ((emacs "27.1")) 10;; Package-Requires: ((emacs "27.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/
@@ -55,7 +55,7 @@
55 55
56;;; Constants ================================================================= 56;;; Constants =================================================================
57 57
58(defconst markdown-mode-version "2.6-alpha" 58(defconst markdown-mode-version "2.7-alpha"
59 "Markdown mode version number.") 59 "Markdown mode version number.")
60 60
61(defconst markdown-output-buffer-name "*markdown-output*" 61(defconst markdown-output-buffer-name "*markdown-output*"
@@ -1317,6 +1317,7 @@ giving the bounds of the current and parent list items."
1317 (not (eobp))) 1317 (not (eobp)))
1318 (forward-line)) 1318 (forward-line))
1319 (skip-syntax-backward "-") 1319 (skip-syntax-backward "-")
1320 (forward-line)
1320 (setq close (point))) 1321 (setq close (point)))
1321 ;; If current line has a list marker, update levels, move to end of block 1322 ;; If current line has a list marker, update levels, move to end of block
1322 ((looking-at markdown-regex-list) 1323 ((looking-at markdown-regex-list)
diff --git a/.emacs.d/lisp/rust-utils.el b/.emacs.d/lisp/rust-utils.el
index 41f1ba8..cb55172 100644
--- a/.emacs.d/lisp/rust-utils.el
+++ b/.emacs.d/lisp/rust-utils.el
@@ -36,46 +36,77 @@ visit the new file."
36 36
37;;; dbg! macro 37;;; dbg! macro
38 38
39(defun rust-insert-dbg () 39(defun rust-insert-dbg-sexp ()
40 "Insert the dbg! macro." 40 "Insert the dbg! macro around a sexp if possible, insert at current position
41 (cond ((region-active-p) 41if not. Move cursor to the end of macro."
42 (when (< (mark) (point)) 42 (when (rust-in-str)
43 (exchange-point-and-mark)) 43 (up-list -1 t t))
44 (let ((old-point (point))) 44 (setq safe-to-forward t)
45 (insert-parentheses) 45 (save-excursion
46 (goto-char old-point))) 46 (condition-case nil
47 (t 47 (forward-sexp)
48 (when (rust-in-str) 48 (error (setq safe-to-forward nil)
49 (up-list -1 t t)) 49 nil)))
50 (insert "(") 50 (cond
51 (forward-sexp) 51 ((not safe-to-forward)
52 (insert ")") 52 (rust-insert-dbg-alone))
53 (backward-sexp))) 53 (t
54 (insert "dbg!")) 54 (insert "(")
55 (forward-sexp)
56 (insert ")")
57 (backward-sexp)
58 (insert "dbg!")
59 (forward-sexp))))
60
61(defun rust-insert-dbg-region ()
62 "Insert the dbg! macro around a region. Move cursor to the end of macro."
63 (when (< (mark) (point))
64 (exchange-point-and-mark))
65 (let ((old-point (point)))
66 (insert-parentheses)
67 (goto-char old-point))
68 (insert "dbg!")
69 (forward-sexp))
70
71(defun rust-insert-dbg-alone ()
72 "Insert the dbg! macro alone. Move cursor in between the brackets."
73 (insert "dbg!()")
74 (backward-char))
55 75
56;;;###autoload 76;;;###autoload
57(defun rust-dbg-wrap-or-unwrap () 77(defun rust-dbg-wrap-or-unwrap ()
58 "Either remove or add the dbg! macro." 78 "Either remove or add the dbg! macro."
59 (interactive) 79 (interactive)
60 (save-excursion 80
61 (if (region-active-p) 81 (cond
62 (rust-insert-dbg) 82
83 ;; region
84 ((region-active-p)
85 (rust-insert-dbg-region))
86
87 ;; alone
88 ((or (looking-at-p " *$") (looking-at-p " *//.*"))
89 (rust-insert-dbg-alone))
63 90
64 (let ((beginning-of-symbol (ignore-errors (beginning-of-thing 'symbol)))) 91 ;; symbol
65 (when beginning-of-symbol 92 (t
66 (goto-char beginning-of-symbol))) 93 (let ((beginning-of-symbol (ignore-errors (beginning-of-thing 'symbol))))
94 (when beginning-of-symbol
95 (goto-char beginning-of-symbol)))
67 96
68 (let ((dbg-point (save-excursion 97 (let ((dbg-point (save-excursion
69 (or (and (looking-at-p "dbg!") (+ 4 (point))) 98 (or (and (looking-at-p "dbg!") (+ 4 (point)))
70 (ignore-errors 99 (ignore-errors
71 (while (not (rust-looking-back-str "dbg!")) 100 (while (not (rust-looking-back-str "dbg!"))
72 (backward-up-list)) 101 (backward-up-list))
73 (point)))))) 102 (point))))))
74 (cond (dbg-point 103 (cond (dbg-point
75 (goto-char dbg-point) 104 (goto-char dbg-point)
76 (delete-char -4) 105 (delete-char -4)
77 (delete-pair)) 106 (delete-pair))
78 (t (rust-insert-dbg))))))) 107 (t (rust-insert-dbg-sexp)))))
108 )
109)
79 110
80(defun rust-toggle-mutability () 111(defun rust-toggle-mutability ()
81 "Toggles the mutability of the variable defined on the current line" 112 "Toggles the mutability of the variable defined on the current line"