From b57f8663d4bd5ee03c55df2f7e0372630b72bab7 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Fri, 28 May 2021 16:34:07 +0200 Subject: Update markdown-mode and yaml-mode --- .emacs.d/lisp/markdown-mode.el | 31 ++++++++++++++++++++++--------- .emacs.d/lisp/yaml-mode.el | 1 + 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 114f9a1..aba9e6f 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -3585,13 +3585,26 @@ prefixed with an integer from 1 to the length of (insert (car markdown-hr-strings)))) (markdown-ensure-blank-line-after)) -(defun markdown--insert-common (start-delim end-delim regex start-group end-group face) +(defun markdown--insert-common (start-delim end-delim regex start-group end-group face + &optional skip-space) (if (use-region-p) ;; Active region - (let ((bounds (markdown-unwrap-things-in-region - (region-beginning) (region-end) - regex start-group end-group))) - (markdown-wrap-or-insert start-delim end-delim nil (car bounds) (cdr bounds))) + (let* ((bounds (markdown-unwrap-things-in-region + (region-beginning) (region-end) + regex start-group end-group)) + (beg (car bounds)) + (end (cdr bounds))) + (when (and beg skip-space) + (save-excursion + (goto-char beg) + (skip-chars-forward "[ \t]") + (setq beg (point)))) + (when (and end skip-space) + (save-excursion + (goto-char end) + (skip-chars-backward "[ \t]") + (setq end (point)))) + (markdown-wrap-or-insert start-delim end-delim nil beg end)) (if (markdown--face-p (point) (list face)) (save-excursion (while (and (markdown--face-p (point) (list face)) (not (bobp))) @@ -3613,7 +3626,7 @@ bold word or phrase, remove the bold markup. Otherwise, simply insert bold delimiters and place the point in between them." (interactive) (let ((delim (if markdown-bold-underscore "__" "**"))) - (markdown--insert-common delim delim markdown-regex-bold 2 4 'markdown-bold-face))) + (markdown--insert-common delim delim markdown-regex-bold 2 4 'markdown-bold-face t))) (defun markdown-insert-italic () "Insert markup to make a region or word italic. @@ -3623,7 +3636,7 @@ italic word or phrase, remove the italic markup. Otherwise, simply insert italic delimiters and place the point in between them." (interactive) (let ((delim (if markdown-italic-underscore "_" "*"))) - (markdown--insert-common delim delim markdown-regex-italic 1 3 'markdown-italic-face))) + (markdown--insert-common delim delim markdown-regex-italic 1 3 'markdown-italic-face t))) (defun markdown-insert-strike-through () "Insert markup to make a region or word strikethrough. @@ -3633,7 +3646,7 @@ strikethrough word or phrase, remove the strikethrough markup. Otherwise, simply insert bold delimiters and place the point in between them." (interactive) (markdown--insert-common - "~~" "~~" markdown-regex-strike-through 2 4 'markdown-strike-through-face)) + "~~" "~~" markdown-regex-strike-through 2 4 'markdown-strike-through-face t)) (defun markdown-insert-code () "Insert markup to make a region or word an inline code fragment. @@ -9074,7 +9087,7 @@ This function assumes point is on a table." (indent (progn (looking-at "[ \t]*") (match-string 0))) ;; Split table in lines and save column format specifier (lines (mapcar (lambda (l) - (if (string-match-p "\\`[ \t]*|[-:]" l) + (if (string-match-p "\\`[ \t]*|[ \t]*[-:]" l) (progn (setq fmtspec (or fmtspec l)) nil) l)) (markdown--split-string (buffer-substring begin end) "\n"))) ;; Split lines in cells diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 50d790b..91db316 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el @@ -5,6 +5,7 @@ ;; Author: Yoshiki Kurihara ;; Marshall T. Vandegrift ;; Maintainer: Vasilij Schneidermann +;; URL: https://github.com/yoshiki/yaml-mode ;; Package-Requires: ((emacs "24.1")) ;; Keywords: data yaml ;; Version: 0.0.15 -- cgit v1.3