From ae4133cda70f515a2d2930dd7e29bcd92ad7d058 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Mon, 10 Jan 2022 20:42:06 +0100 Subject: Update markdown-mode and yaml-mode --- .emacs.d/lisp/markdown-mode.el | 28 ++++++++++++--------- .emacs.d/lisp/yaml-mode.el | 56 ++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 9c52cd3..a4d08fd 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -2656,7 +2656,8 @@ intact additional processing." (match-beginning 5) (match-end 5))))))))) (defun markdown-get-defined-references () - "Return all defined reference labels and their line numbers (not including square brackets)." + "Return all defined reference labels and their line numbers. +They does not include square brackets)." (save-excursion (goto-char (point-min)) (let (refs) @@ -3916,7 +3917,7 @@ This is an internal function called by (markdown-insert-uri uri)))))) (defun markdown-insert-link () - "Insert new or update an existing link, with interactive prompts. + "Insert new or update an existing link, with interactive prompt. If the point is at an existing link or URL, update the link text, URL, reference label, and/or title. Otherwise, insert a new link. The type of link inserted (inline, reference, or plain URL) @@ -3951,7 +3952,7 @@ selectively adding or removing information via the prompts." (markdown--insert-link-or-image nil)) (defun markdown-insert-image () - "Insert new or update an existing image, with interactive prompts. + "Insert new or update an existing image, with interactive prompt. If the point is at an existing image, update the alt text, URL, reference label, and/or title. Otherwise, insert a new image. The type of image inserted (inline or reference) depends on which @@ -8233,6 +8234,9 @@ markers and footnote text." ;; Reference definition ((thing-at-point-looking-at markdown-regex-reference-definition) (markdown-reference-goto-link (match-string-no-properties 2))) + ;; Link + ((or (markdown-link-p) (markdown-wiki-link-p)) + (markdown-follow-thing-at-point nil)) ;; GFM task list item ((markdown-gfm-task-list-item-at-point) (markdown-toggle-gfm-checkbox)) @@ -8797,7 +8801,8 @@ at the END of code blocks." (goto-char (- beg 1)) (let ((block-indentation (current-indentation))) (when (> block-indentation 0) - (indent-rigidly beg end block-indentation)))) + (indent-rigidly beg end block-indentation))) + (font-lock-ensure)) (defun markdown-edit-code-block () "Edit Markdown code block in an indirect buffer." @@ -8805,8 +8810,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 (goto-char (nth 0 bounds)) (point-at-bol 2))) - (end (and bounds (goto-char (nth 1 bounds)) (point-at-bol 1)))) + (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)))) (if (and begin end) (let* ((indentation (and (goto-char (nth 0 bounds)) (current-indentation))) (lang (markdown-code-block-lang)) @@ -8816,7 +8821,7 @@ at the END of code blocks." (lambda (_parent-buffer _beg _end) (funcall mode))) (indirect-buf (edit-indirect-region begin end 'display-buffer))) - ;; reset `sh-shell' when indirect buffer + ;; reset `sh-shell' when indirect buffer (when (and (not (member system-type '(ms-dos windows-nt))) (member mode '(shell-script-mode sh-mode)) (member lang (append @@ -9640,22 +9645,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)) diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 9d619d5..666f128 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el @@ -1,4 +1,4 @@ -;;; yaml-mode.el --- Major mode for editing YAML files +;;; yaml-mode.el --- Major mode for editing YAML files -*- lexical-binding: t -*- ;; Copyright (C) 2010-2014 Yoshiki Kurihara @@ -12,19 +12,18 @@ ;; This file is not part of Emacs -;; This file is free software; you can redistribute it and/or modify +;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. -;; This file is distributed in the hope that it will be useful, +;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. -;; You should have received a copy of the GNU General Public License along -;; with this program; if not, write to the Free Software Foundation, Inc., -;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . ;;; Commentary: @@ -103,8 +102,8 @@ that key is pressed to begin a block literal." :group 'yaml) (defface yaml-tab-face - '((((class color)) (:background "red" :foreground "red" :bold t)) - (t (:reverse-video t))) + '((((class color)) (:background "red" :foreground "red" :bold t)) + (t (:reverse-video t))) "Face to use for highlighting tabs in YAML files." :group 'faces :group 'yaml) @@ -243,7 +242,7 @@ that key is pressed to begin a block literal." (,yaml-document-delimiter-re . (0 font-lock-comment-face)) (,yaml-directive-re . (1 font-lock-builtin-face)) ("^[\t]+" 0 'yaml-tab-face t)) - "Additional expressions to highlight in YAML mode.") + "Additional expressions to highlight in YAML mode.") (defun yaml-mode-syntax-propertize-function (beg end) "Override buffer's syntax table for special syntactic constructs." @@ -367,7 +366,6 @@ back-dent the line by `yaml-indent-offset' spaces. On reaching column 0, it will cycle back to the maximum sensible indentation." (interactive "*") (let ((ci (current-indentation)) - (cc (current-column)) (need (yaml-compute-indentation))) (save-excursion (beginning-of-line) @@ -432,27 +430,27 @@ otherwise do nothing." (while (and (looking-at-p yaml-blank-line-re) (not (bobp))) (forward-line -1)) (let ((nlines yaml-block-literal-search-lines) - (min-level (current-indentation)) - beg) + (min-level (current-indentation)) + beg) (forward-line -1) (while (and (/= nlines 0) - (/= min-level 0) - (not (looking-at-p yaml-block-literal-re)) - (not (bobp))) - (setq nlines (1- nlines)) - (unless (looking-at-p yaml-blank-line-re) - (setq min-level (min min-level (current-indentation)))) - (forward-line -1)) + (/= min-level 0) + (not (looking-at-p yaml-block-literal-re)) + (not (bobp))) + (setq nlines (1- nlines)) + (unless (looking-at-p yaml-blank-line-re) + (setq min-level (min min-level (current-indentation)))) + (forward-line -1)) (when (and (< (current-indentation) min-level) (looking-at-p yaml-block-literal-re)) - (setq min-level (current-indentation)) - (forward-line) - (setq beg (point)) - (while (and (not (eobp)) - (or (looking-at-p yaml-blank-line-re) - (> (current-indentation) min-level))) - (forward-line)) - (narrow-to-region beg (point)))))) + (setq min-level (current-indentation)) + (forward-line) + (setq beg (point)) + (while (and (not (eobp)) + (or (looking-at-p yaml-blank-line-re) + (> (current-indentation) min-level))) + (forward-line)) + (narrow-to-region beg (point)))))) (defun yaml-fill-paragraph (&optional justify region) "Fill paragraph. -- cgit v1.3