diff options
| author | Simeon Simeonov | 2021-08-10 21:49:01 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2021-08-10 21:49:01 +0200 |
| commit | 32d6065654ea0b582774cbfda318a79babcffd2b (patch) | |
| tree | b17e27f0f1595b49eade9cafa7783bfdde838036 | |
| parent | f5006c71f40842314efab7149916ca08058cfa77 (diff) | |
Update markdown-mode and yaml-mode
| -rw-r--r-- | .emacs.d/lisp/markdown-mode.el | 232 | ||||
| -rw-r--r-- | .emacs.d/lisp/yaml-mode.el | 4 |
2 files changed, 146 insertions, 90 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 502eb26..b42760e 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el | |||
| @@ -47,8 +47,10 @@ | |||
| 47 | (defvar jit-lock-end) | 47 | (defvar jit-lock-end) |
| 48 | (defvar flyspell-generic-check-word-predicate) | 48 | (defvar flyspell-generic-check-word-predicate) |
| 49 | (defvar electric-pair-pairs) | 49 | (defvar electric-pair-pairs) |
| 50 | (defvar sh-ancestor-alist) | ||
| 50 | 51 | ||
| 51 | (declare-function project-roots "project") | 52 | (declare-function project-roots "project") |
| 53 | (declare-function sh-set-shell "sh-script") | ||
| 52 | 54 | ||
| 53 | 55 | ||
| 54 | ;;; Constants ================================================================= | 56 | ;;; Constants ================================================================= |
| @@ -498,7 +500,7 @@ If this value is 'any and `display-buffer-alist' is set then | |||
| 498 | :package-version '(markdown-mode . "2.2")) | 500 | :package-version '(markdown-mode . "2.2")) |
| 499 | 501 | ||
| 500 | (defcustom markdown-live-preview-window-function | 502 | (defcustom markdown-live-preview-window-function |
| 501 | 'markdown-live-preview-window-eww | 503 | #'markdown-live-preview-window-eww |
| 502 | "Function to display preview of Markdown output within Emacs. | 504 | "Function to display preview of Markdown output within Emacs. |
| 503 | Function must update the buffer containing the preview and return | 505 | Function must update the buffer containing the preview and return |
| 504 | the buffer." | 506 | the buffer." |
| @@ -617,7 +619,14 @@ requires Emacs to be built with ImageMagick support." | |||
| 617 | "Non-nil means mouse on a link will follow the link. | 619 | "Non-nil means mouse on a link will follow the link. |
| 618 | This variable must be set before loading markdown-mode." | 620 | This variable must be set before loading markdown-mode." |
| 619 | :group 'markdown | 621 | :group 'markdown |
| 620 | :type 'bool | 622 | :type 'boolean |
| 623 | :safe 'booleanp | ||
| 624 | :package-version '(markdown-mode . "2.5")) | ||
| 625 | |||
| 626 | (defcustom markdown-table-align-p t | ||
| 627 | "Non-nil means that table is aligned after table operation." | ||
| 628 | :group 'markdown | ||
| 629 | :type 'boolean | ||
| 621 | :safe 'booleanp | 630 | :safe 'booleanp |
| 622 | :package-version '(markdown-mode . "2.5")) | 631 | :package-version '(markdown-mode . "2.5")) |
| 623 | 632 | ||
| @@ -1098,9 +1107,16 @@ Function is called repeatedly until it returns nil. For details, see | |||
| 1098 | (max end (match-beginning 0)) | 1107 | (max end (match-beginning 0)) |
| 1099 | (point-max)))) | 1108 | (point-max)))) |
| 1100 | (code-match (markdown-code-block-at-pos new-start)) | 1109 | (code-match (markdown-code-block-at-pos new-start)) |
| 1101 | (new-start (or (and code-match (cl-first code-match)) new-start)) | 1110 | ;; FIXME: The `code-match' can return bogus values |
| 1102 | (code-match (and (< end (point-max)) (markdown-code-block-at-pos end))) | 1111 | ;; when text has been inserted/deleted! |
| 1103 | (new-end (or (and code-match (cl-second code-match)) new-end))) | 1112 | (new-start (min (or (and code-match (cl-first code-match)) |
| 1113 | (point-max)) | ||
| 1114 | new-start)) | ||
| 1115 | (code-match (and (< end (point-max)) | ||
| 1116 | (markdown-code-block-at-pos end))) | ||
| 1117 | (new-end (max (or (and code-match (cl-second code-match)) 0) | ||
| 1118 | new-end))) | ||
| 1119 | |||
| 1104 | (unless (and (eq new-start start) (eq new-end end)) | 1120 | (unless (and (eq new-start start) (eq new-end end)) |
| 1105 | (cons new-start (min new-end (point-max)))))))) | 1121 | (cons new-start (min new-end (point-max)))))))) |
| 1106 | 1122 | ||
| @@ -1536,7 +1552,8 @@ MIDDLE-BEGIN is the start of the \"middle\" section of the block." | |||
| 1536 | (cl-third fence-spec) | 1552 | (cl-third fence-spec) |
| 1537 | (list middle-begin close-begin)) | 1553 | (list middle-begin close-begin)) |
| 1538 | ;; If the block is a YAML block, propertize the declarations inside | 1554 | ;; If the block is a YAML block, propertize the declarations inside |
| 1539 | (markdown-syntax-propertize-yaml-metadata middle-begin close-begin) | 1555 | (when (< middle-begin close-begin) ;; workaround #634 |
| 1556 | (markdown-syntax-propertize-yaml-metadata middle-begin close-begin)) | ||
| 1540 | ;; Propertize closing line of fenced block. | 1557 | ;; Propertize closing line of fenced block. |
| 1541 | (put-text-property close-begin close-end | 1558 | (put-text-property close-begin close-end |
| 1542 | (cl-cadadr fence-spec) close-data)))) | 1559 | (cl-cadadr fence-spec) close-data)))) |
| @@ -1969,7 +1986,7 @@ When non-nil, `markdown-header-face' will inherit from | |||
| 1969 | `markdown-header-scaling-values' will be applied to | 1986 | `markdown-header-scaling-values' will be applied to |
| 1970 | headers of levels one through six respectively." | 1987 | headers of levels one through six respectively." |
| 1971 | :type 'boolean | 1988 | :type 'boolean |
| 1972 | :initialize 'custom-initialize-default | 1989 | :initialize #'custom-initialize-default |
| 1973 | :set (lambda (symbol value) | 1990 | :set (lambda (symbol value) |
| 1974 | (set-default symbol value) | 1991 | (set-default symbol value) |
| 1975 | (markdown-update-header-faces value)) | 1992 | (markdown-update-header-faces value)) |
| @@ -1981,37 +1998,39 @@ headers of levels one through six respectively." | |||
| 1981 | "List of scaling values for headers of level one through six. | 1998 | "List of scaling values for headers of level one through six. |
| 1982 | Used when `markdown-header-scaling' is non-nil." | 1999 | Used when `markdown-header-scaling' is non-nil." |
| 1983 | :type 'list | 2000 | :type 'list |
| 1984 | :initialize 'custom-initialize-default | 2001 | :initialize #'custom-initialize-default |
| 1985 | :set (lambda (symbol value) | 2002 | :set (lambda (symbol value) |
| 1986 | (set-default symbol value) | 2003 | (set-default symbol value) |
| 1987 | (markdown-update-header-faces markdown-header-scaling value)) | 2004 | (markdown-update-header-faces markdown-header-scaling value))) |
| 1988 | :group 'markdown-faces) | ||
| 1989 | 2005 | ||
| 1990 | (defun markdown-make-header-faces () | 2006 | (defmacro markdown--dotimes-when-compile (i-n body) |
| 1991 | "Build the faces used for Markdown headers." | 2007 | (declare (indent 1) (debug ((symbolp form) form))) |
| 1992 | (let ((inherit-faces '(font-lock-function-name-face))) | 2008 | (let ((var (car i-n)) |
| 1993 | (when markdown-header-scaling | 2009 | (n (cadr i-n)) |
| 1994 | (setq inherit-faces (cons 'variable-pitch inherit-faces))) | 2010 | (code ())) |
| 1995 | (defface markdown-header-face | 2011 | (dotimes (i (eval n t)) |
| 1996 | `((t (:inherit ,inherit-faces :weight bold))) | 2012 | (push (eval body `((,var . ,i))) code)) |
| 1997 | "Base face for headers." | 2013 | `(progn ,@(nreverse code)))) |
| 1998 | :group 'markdown-faces)) | 2014 | |
| 1999 | (dotimes (num 6) | 2015 | (defface markdown-header-face |
| 2000 | (let* ((num1 (1+ num)) | 2016 | `((t (:inherit (,@(when markdown-header-scaling '(variable-pitch)) |
| 2001 | (face-name (intern (format "markdown-header-face-%s" num1))) | 2017 | font-lock-function-name-face) |
| 2002 | (scale (if markdown-header-scaling | 2018 | :weight bold))) |
| 2003 | (float (nth num markdown-header-scaling-values)) | 2019 | "Base face for headers.") |
| 2004 | 1.0))) | 2020 | |
| 2005 | (eval | 2021 | (markdown--dotimes-when-compile (num 6) |
| 2006 | `(defface ,face-name | 2022 | (let* ((num1 (1+ num)) |
| 2007 | '((t (:inherit markdown-header-face :height ,scale))) | 2023 | (face-name (intern (format "markdown-header-face-%s" num1)))) |
| 2008 | (format "Face for level %s headers. | 2024 | `(defface ,face-name |
| 2025 | (,'\` ((t (:inherit markdown-header-face | ||
| 2026 | :height | ||
| 2027 | (,'\, (if markdown-header-scaling | ||
| 2028 | (float (nth ,num markdown-header-scaling-values)) | ||
| 2029 | 1.0)))))) | ||
| 2030 | (format "Face for level %s headers. | ||
| 2009 | You probably don't want to customize this face directly. Instead | 2031 | You probably don't want to customize this face directly. Instead |
| 2010 | you can customize the base face `markdown-header-face' or the | 2032 | you can customize the base face `markdown-header-face' or the |
| 2011 | variable-height variable `markdown-header-scaling'." ,num1) | 2033 | variable-height variable `markdown-header-scaling'." ,num1)))) |
| 2012 | :group 'markdown-faces))))) | ||
| 2013 | |||
| 2014 | (markdown-make-header-faces) | ||
| 2015 | 2034 | ||
| 2016 | (defun markdown-update-header-faces (&optional scaling scaling-values) | 2035 | (defun markdown-update-header-faces (&optional scaling scaling-values) |
| 2017 | "Update header faces, depending on if header SCALING is desired. | 2036 | "Update header faces, depending on if header SCALING is desired. |
| @@ -3299,17 +3318,24 @@ Group 7: closing filename delimiter" | |||
| 3299 | 3318 | ||
| 3300 | ;;; Markdown Font Fontification Functions ===================================== | 3319 | ;;; Markdown Font Fontification Functions ===================================== |
| 3301 | 3320 | ||
| 3321 | (defvar markdown--first-displayable-cache (make-hash-table :test #'equal)) | ||
| 3322 | |||
| 3302 | (defun markdown--first-displayable (seq) | 3323 | (defun markdown--first-displayable (seq) |
| 3303 | "Return the first displayable character or string in SEQ. | 3324 | "Return the first displayable character or string in SEQ. |
| 3304 | SEQ may be an atom or a sequence." | 3325 | SEQ may be an atom or a sequence." |
| 3305 | (let ((seq (if (listp seq) seq (list seq)))) | 3326 | (let ((c (gethash seq markdown--first-displayable-cache t))) |
| 3306 | (cond ((stringp (car seq)) | 3327 | (if (not (eq c t)) |
| 3307 | (cl-find-if | 3328 | c |
| 3308 | (lambda (str) | 3329 | (puthash seq |
| 3309 | (and (mapcar #'char-displayable-p (string-to-list str)))) | 3330 | (let ((seq (if (listp seq) seq (list seq)))) |
| 3310 | seq)) | 3331 | (cond ((stringp (car seq)) |
| 3311 | ((characterp (car seq)) | 3332 | (cl-find-if |
| 3312 | (cl-find-if #'char-displayable-p seq))))) | 3333 | (lambda (str) |
| 3334 | (and (mapcar #'char-displayable-p (string-to-list str)))) | ||
| 3335 | seq)) | ||
| 3336 | ((characterp (car seq)) | ||
| 3337 | (cl-find-if #'char-displayable-p seq)))) | ||
| 3338 | markdown--first-displayable-cache)))) | ||
| 3313 | 3339 | ||
| 3314 | (defun markdown--marginalize-string (level) | 3340 | (defun markdown--marginalize-string (level) |
| 3315 | "Generate atx markup string of given LEVEL for left margin." | 3341 | "Generate atx markup string of given LEVEL for left margin." |
| @@ -3394,7 +3420,8 @@ SEQ may be an atom or a sequence." | |||
| 3394 | 3420 | ||
| 3395 | (defun markdown-fontify-list-items (last) | 3421 | (defun markdown-fontify-list-items (last) |
| 3396 | "Apply font-lock properties to list markers from point to LAST." | 3422 | "Apply font-lock properties to list markers from point to LAST." |
| 3397 | (when (markdown-match-list-items last) | 3423 | (when (and (markdown-match-list-items last) |
| 3424 | (not (markdown-code-block-at-point-p (match-beginning 2)))) | ||
| 3398 | (let* ((indent (length (match-string-no-properties 1))) | 3425 | (let* ((indent (length (match-string-no-properties 1))) |
| 3399 | (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ... | 3426 | (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ... |
| 3400 | (bullet (nth (mod level (length markdown-list-item-bullets)) | 3427 | (bullet (nth (mod level (length markdown-list-item-bullets)) |
| @@ -4890,7 +4917,7 @@ duplicate positions, which are handled up by calling functions." | |||
| 4890 | ;; Return reversed list | 4917 | ;; Return reversed list |
| 4891 | (reverse positions))) | 4918 | (reverse positions))) |
| 4892 | 4919 | ||
| 4893 | (defun markdown-enter-key () | 4920 | (defun markdown-enter-key () ;FIXME: Partly obsoleted by electric-indent |
| 4894 | "Handle RET depending on the context. | 4921 | "Handle RET depending on the context. |
| 4895 | If the point is at a table, move to the next row. Otherwise, | 4922 | If the point is at a table, move to the next row. Otherwise, |
| 4896 | indent according to value of `markdown-indent-on-enter'. | 4923 | indent according to value of `markdown-indent-on-enter'. |
| @@ -5097,7 +5124,7 @@ Handle all elements of `markdown-complete-alist' in order." | |||
| 5097 | (interactive "*") | 5124 | (interactive "*") |
| 5098 | (let ((list markdown-complete-alist) found changed) | 5125 | (let ((list markdown-complete-alist) found changed) |
| 5099 | (while list | 5126 | (while list |
| 5100 | (let ((regexp (eval (caar list))) | 5127 | (let ((regexp (eval (caar list) t)) ;FIXME: Why `eval'? |
| 5101 | (function (cdar list))) | 5128 | (function (cdar list))) |
| 5102 | (setq list (cdr list)) | 5129 | (setq list (cdr list)) |
| 5103 | (when (thing-at-point-looking-at regexp) | 5130 | (when (thing-at-point-looking-at regexp) |
| @@ -5117,7 +5144,7 @@ match." | |||
| 5117 | (let ((end-marker (set-marker (make-marker) end)) | 5144 | (let ((end-marker (set-marker (make-marker) end)) |
| 5118 | previous) | 5145 | previous) |
| 5119 | (dolist (element markdown-complete-alist) | 5146 | (dolist (element markdown-complete-alist) |
| 5120 | (let ((regexp (eval (car element))) | 5147 | (let ((regexp (eval (car element) t)) ;FIXME: Why `eval'? |
| 5121 | (function (cdr element))) | 5148 | (function (cdr element))) |
| 5122 | (goto-char beg) | 5149 | (goto-char beg) |
| 5123 | (while (re-search-forward regexp end-marker 'limit) | 5150 | (while (re-search-forward regexp end-marker 'limit) |
| @@ -5324,14 +5351,16 @@ Assumes match data is available for `markdown-regex-italic'." | |||
| 5324 | (define-key map (kbd "C-c C-d") 'markdown-do) | 5351 | (define-key map (kbd "C-c C-d") 'markdown-do) |
| 5325 | (define-key map (kbd "C-c '") 'markdown-edit-code-block) | 5352 | (define-key map (kbd "C-c '") 'markdown-edit-code-block) |
| 5326 | ;; Indentation | 5353 | ;; Indentation |
| 5327 | (define-key map (kbd "C-m") 'markdown-enter-key) | 5354 | (define-key map (kbd "RET") 'markdown-enter-key) |
| 5328 | (define-key map (kbd "DEL") 'markdown-outdent-or-delete) | 5355 | (define-key map (kbd "DEL") 'markdown-outdent-or-delete) |
| 5329 | (define-key map (kbd "C-c >") 'markdown-indent-region) | 5356 | (define-key map (kbd "C-c >") 'markdown-indent-region) |
| 5330 | (define-key map (kbd "C-c <") 'markdown-outdent-region) | 5357 | (define-key map (kbd "C-c <") 'markdown-outdent-region) |
| 5331 | ;; Visibility cycling | 5358 | ;; Visibility cycling |
| 5332 | (define-key map (kbd "TAB") 'markdown-cycle) | 5359 | (define-key map (kbd "TAB") 'markdown-cycle) |
| 5333 | (define-key map (kbd "<S-iso-lefttab>") 'markdown-shifttab) | 5360 | ;; S-iso-lefttab and S-tab should both be mapped to `backtab' by |
| 5334 | (define-key map (kbd "<S-tab>") 'markdown-shifttab) | 5361 | ;; (local-)function-key-map. |
| 5362 | ;;(define-key map (kbd "<S-iso-lefttab>") 'markdown-shifttab) | ||
| 5363 | ;;(define-key map (kbd "<S-tab>") 'markdown-shifttab) | ||
| 5335 | (define-key map (kbd "<backtab>") 'markdown-shifttab) | 5364 | (define-key map (kbd "<backtab>") 'markdown-shifttab) |
| 5336 | ;; Heading and list navigation | 5365 | ;; Heading and list navigation |
| 5337 | (define-key map (kbd "C-c C-n") 'markdown-outline-next) | 5366 | (define-key map (kbd "C-c C-n") 'markdown-outline-next) |
| @@ -5682,6 +5711,7 @@ See `imenu-create-index-function' and `imenu--index-alist' for details." | |||
| 5682 | (setcdr sibling-alist alist) | 5711 | (setcdr sibling-alist alist) |
| 5683 | (setq cur-alist alist)) | 5712 | (setq cur-alist alist)) |
| 5684 | (setq cur-level level))))) | 5713 | (setq cur-level level))))) |
| 5714 | (setq root (copy-tree root)) | ||
| 5685 | ;; Footnotes | 5715 | ;; Footnotes |
| 5686 | (let ((fn (markdown-get-defined-footnotes))) | 5716 | (let ((fn (markdown-get-defined-footnotes))) |
| 5687 | (if (or (zerop (length fn)) | 5717 | (if (or (zerop (length fn)) |
| @@ -7031,8 +7061,8 @@ ones already marked." | |||
| 7031 | (goto-char (mark)) | 7061 | (goto-char (mark)) |
| 7032 | (markdown-forward-paragraph) | 7062 | (markdown-forward-paragraph) |
| 7033 | (point))) | 7063 | (point))) |
| 7034 | (let ((beginning-of-defun-function 'markdown-backward-paragraph) | 7064 | (let ((beginning-of-defun-function #'markdown-backward-paragraph) |
| 7035 | (end-of-defun-function 'markdown-forward-paragraph)) | 7065 | (end-of-defun-function #'markdown-forward-paragraph)) |
| 7036 | (mark-defun)))) | 7066 | (mark-defun)))) |
| 7037 | 7067 | ||
| 7038 | (defun markdown-mark-block () | 7068 | (defun markdown-mark-block () |
| @@ -7050,16 +7080,16 @@ ones already marked." | |||
| 7050 | (goto-char (mark)) | 7080 | (goto-char (mark)) |
| 7051 | (markdown-forward-block) | 7081 | (markdown-forward-block) |
| 7052 | (point))) | 7082 | (point))) |
| 7053 | (let ((beginning-of-defun-function 'markdown-backward-block) | 7083 | (let ((beginning-of-defun-function #'markdown-backward-block) |
| 7054 | (end-of-defun-function 'markdown-forward-block)) | 7084 | (end-of-defun-function #'markdown-forward-block)) |
| 7055 | (mark-defun)))) | 7085 | (mark-defun)))) |
| 7056 | 7086 | ||
| 7057 | (defun markdown-narrow-to-block () | 7087 | (defun markdown-narrow-to-block () |
| 7058 | "Make text outside current block invisible. | 7088 | "Make text outside current block invisible. |
| 7059 | The current block is the one that contains point or follows point." | 7089 | The current block is the one that contains point or follows point." |
| 7060 | (interactive) | 7090 | (interactive) |
| 7061 | (let ((beginning-of-defun-function 'markdown-backward-block) | 7091 | (let ((beginning-of-defun-function #'markdown-backward-block) |
| 7062 | (end-of-defun-function 'markdown-forward-block)) | 7092 | (end-of-defun-function #'markdown-forward-block)) |
| 7063 | (narrow-to-defun))) | 7093 | (narrow-to-defun))) |
| 7064 | 7094 | ||
| 7065 | (defun markdown-mark-text-block () | 7095 | (defun markdown-mark-text-block () |
| @@ -7077,8 +7107,8 @@ ones already marked." | |||
| 7077 | (goto-char (mark)) | 7107 | (goto-char (mark)) |
| 7078 | (markdown-end-of-text-block) | 7108 | (markdown-end-of-text-block) |
| 7079 | (point))) | 7109 | (point))) |
| 7080 | (let ((beginning-of-defun-function 'markdown-beginning-of-text-block) | 7110 | (let ((beginning-of-defun-function #'markdown-beginning-of-text-block) |
| 7081 | (end-of-defun-function 'markdown-end-of-text-block)) | 7111 | (end-of-defun-function #'markdown-end-of-text-block)) |
| 7082 | (mark-defun)))) | 7112 | (mark-defun)))) |
| 7083 | 7113 | ||
| 7084 | (defun markdown-mark-page () | 7114 | (defun markdown-mark-page () |
| @@ -7097,16 +7127,16 @@ ones already marked." | |||
| 7097 | (goto-char (mark)) | 7127 | (goto-char (mark)) |
| 7098 | (markdown-forward-page) | 7128 | (markdown-forward-page) |
| 7099 | (point))) | 7129 | (point))) |
| 7100 | (let ((beginning-of-defun-function 'markdown-backward-page) | 7130 | (let ((beginning-of-defun-function #'markdown-backward-page) |
| 7101 | (end-of-defun-function 'markdown-forward-page)) | 7131 | (end-of-defun-function #'markdown-forward-page)) |
| 7102 | (mark-defun)))) | 7132 | (mark-defun)))) |
| 7103 | 7133 | ||
| 7104 | (defun markdown-narrow-to-page () | 7134 | (defun markdown-narrow-to-page () |
| 7105 | "Make text outside current top level section invisible. | 7135 | "Make text outside current top level section invisible. |
| 7106 | The current section is the one that contains point or follows point." | 7136 | The current section is the one that contains point or follows point." |
| 7107 | (interactive) | 7137 | (interactive) |
| 7108 | (let ((beginning-of-defun-function 'markdown-backward-page) | 7138 | (let ((beginning-of-defun-function #'markdown-backward-page) |
| 7109 | (end-of-defun-function 'markdown-forward-page)) | 7139 | (end-of-defun-function #'markdown-forward-page)) |
| 7110 | (narrow-to-defun))) | 7140 | (narrow-to-defun))) |
| 7111 | 7141 | ||
| 7112 | (defun markdown-mark-subtree () | 7142 | (defun markdown-mark-subtree () |
| @@ -7731,15 +7761,17 @@ returns nil." | |||
| 7731 | (process-file markdown-open-image-command nil nil nil link-file)) | 7761 | (process-file markdown-open-image-command nil nil nil link-file)) |
| 7732 | (find-file link-file))))))) | 7762 | (find-file link-file))))))) |
| 7733 | 7763 | ||
| 7734 | (defun markdown-follow-link-at-point () | 7764 | (defun markdown-follow-link-at-point (&optional event) |
| 7735 | "Open the current non-wiki link. | 7765 | "Open the non-wiki link at point or EVENT. |
| 7736 | If the link is a complete URL, open in browser with `browse-url'. | 7766 | If the link is a complete URL, open in browser with `browse-url'. |
| 7737 | Otherwise, open with `find-file' after stripping anchor and/or query string. | 7767 | Otherwise, open with `find-file' after stripping anchor and/or query string. |
| 7738 | Translate filenames using `markdown-filename-translate-function'." | 7768 | Translate filenames using `markdown-filename-translate-function'." |
| 7739 | (interactive) | 7769 | (interactive (list last-command-event)) |
| 7740 | (if (markdown-link-p) | 7770 | (save-excursion |
| 7741 | (markdown--browse-url (markdown-link-url)) | 7771 | (if event (posn-set-point (event-start event))) |
| 7742 | (user-error "Point is not at a Markdown link or URL"))) | 7772 | (if (markdown-link-p) |
| 7773 | (markdown--browse-url (markdown-link-url)) | ||
| 7774 | (user-error "Point is not at a Markdown link or URL")))) | ||
| 7743 | 7775 | ||
| 7744 | (defun markdown-fontify-inline-links (last) | 7776 | (defun markdown-fontify-inline-links (last) |
| 7745 | "Add text properties to next inline link from point to LAST." | 7777 | "Add text properties to next inline link from point to LAST." |
| @@ -8117,9 +8149,9 @@ These are only enabled when `markdown-wiki-link-fontify-missing' is non-nil." | |||
| 8117 | (if (and markdown-enable-wiki-links | 8149 | (if (and markdown-enable-wiki-links |
| 8118 | markdown-wiki-link-fontify-missing) | 8150 | markdown-wiki-link-fontify-missing) |
| 8119 | (add-hook 'after-change-functions | 8151 | (add-hook 'after-change-functions |
| 8120 | 'markdown-check-change-for-wiki-link-after-change t t) | 8152 | #'markdown-check-change-for-wiki-link-after-change t t) |
| 8121 | (remove-hook 'after-change-functions | 8153 | (remove-hook 'after-change-functions |
| 8122 | 'markdown-check-change-for-wiki-link-after-change t)) | 8154 | #'markdown-check-change-for-wiki-link-after-change t)) |
| 8123 | ;; If we left the buffer there is a really good chance we were | 8155 | ;; If we left the buffer there is a really good chance we were |
| 8124 | ;; creating one of the wiki link documents. Make sure we get | 8156 | ;; creating one of the wiki link documents. Make sure we get |
| 8125 | ;; refontified when we come back. | 8157 | ;; refontified when we come back. |
| @@ -8127,10 +8159,10 @@ These are only enabled when `markdown-wiki-link-fontify-missing' is non-nil." | |||
| 8127 | markdown-wiki-link-fontify-missing) | 8159 | markdown-wiki-link-fontify-missing) |
| 8128 | (progn | 8160 | (progn |
| 8129 | (add-hook 'window-configuration-change-hook | 8161 | (add-hook 'window-configuration-change-hook |
| 8130 | 'markdown-fontify-buffer-wiki-links t t) | 8162 | #'markdown-fontify-buffer-wiki-links t t) |
| 8131 | (markdown-fontify-buffer-wiki-links)) | 8163 | (markdown-fontify-buffer-wiki-links)) |
| 8132 | (remove-hook 'window-configuration-change-hook | 8164 | (remove-hook 'window-configuration-change-hook |
| 8133 | 'markdown-fontify-buffer-wiki-links t) | 8165 | #'markdown-fontify-buffer-wiki-links t) |
| 8134 | (markdown-unfontify-region-wiki-links (point-min) (point-max)))) | 8166 | (markdown-unfontify-region-wiki-links (point-min) (point-max)))) |
| 8135 | 8167 | ||
| 8136 | 8168 | ||
| @@ -8593,7 +8625,7 @@ mode to use. The language to mode mapping may be customized by | |||
| 8593 | setting the variable `markdown-code-lang-modes'." | 8625 | setting the variable `markdown-code-lang-modes'." |
| 8594 | :group 'markdown | 8626 | :group 'markdown |
| 8595 | :type 'boolean | 8627 | :type 'boolean |
| 8596 | :safe 'booleanp | 8628 | :safe #'booleanp |
| 8597 | :package-version '(markdown-mode . "2.3")) | 8629 | :package-version '(markdown-mode . "2.3")) |
| 8598 | 8630 | ||
| 8599 | (defcustom markdown-fontify-code-block-default-mode nil | 8631 | (defcustom markdown-fontify-code-block-default-mode nil |
| @@ -8756,6 +8788,15 @@ at the END of code blocks." | |||
| 8756 | (lambda (_parent-buffer _beg _end) | 8788 | (lambda (_parent-buffer _beg _end) |
| 8757 | (funcall mode))) | 8789 | (funcall mode))) |
| 8758 | (indirect-buf (edit-indirect-region begin end 'display-buffer))) | 8790 | (indirect-buf (edit-indirect-region begin end 'display-buffer))) |
| 8791 | ;; reset `sh-shell' when indirect buffer | ||
| 8792 | (when (and (not (member system-type '(ms-dos windows-nt))) | ||
| 8793 | (member mode '(shell-script-mode sh-mode)) | ||
| 8794 | (member lang (append | ||
| 8795 | (mapcar (lambda (e) (symbol-name (car e))) | ||
| 8796 | sh-ancestor-alist) | ||
| 8797 | '("csh" "rc" "sh")))) | ||
| 8798 | (with-current-buffer indirect-buf | ||
| 8799 | (sh-set-shell lang))) | ||
| 8759 | (when (> indentation 0) ;; un-indent in edit-indirect buffer | 8800 | (when (> indentation 0) ;; un-indent in edit-indirect buffer |
| 8760 | (with-current-buffer indirect-buf | 8801 | (with-current-buffer indirect-buf |
| 8761 | (indent-rigidly (point-min) (point-max) (- indentation))))) | 8802 | (indent-rigidly (point-min) (point-max) (- indentation))))) |
| @@ -8837,7 +8878,7 @@ This version removes characters with invisibility property | |||
| 8837 | 8878 | ||
| 8838 | ;; Functions for maintaining tables | 8879 | ;; Functions for maintaining tables |
| 8839 | 8880 | ||
| 8840 | (defvar markdown-table-at-point-p-function nil | 8881 | (defvar markdown-table-at-point-p-function #'markdown--table-at-point-p |
| 8841 | "Function to decide if point is inside a table. | 8882 | "Function to decide if point is inside a table. |
| 8842 | 8883 | ||
| 8843 | The indirection serves to differentiate between standard markdown | 8884 | The indirection serves to differentiate between standard markdown |
| @@ -8854,9 +8895,7 @@ tables and gfm tables which are less strict about the markup.") | |||
| 8854 | 8895 | ||
| 8855 | (defun markdown-table-at-point-p () | 8896 | (defun markdown-table-at-point-p () |
| 8856 | "Return non-nil when point is inside a table." | 8897 | "Return non-nil when point is inside a table." |
| 8857 | (if (functionp markdown-table-at-point-p-function) | 8898 | (funcall markdown-table-at-point-p-function)) |
| 8858 | (funcall markdown-table-at-point-p-function) | ||
| 8859 | (markdown--table-at-point-p))) | ||
| 8860 | 8899 | ||
| 8861 | (defun markdown--table-at-point-p () | 8900 | (defun markdown--table-at-point-p () |
| 8862 | "Return non-nil when point is inside a table." | 8901 | "Return non-nil when point is inside a table." |
| @@ -8961,7 +9000,8 @@ This function assumes point is on a table." | |||
| 8961 | (save-excursion | 9000 | (save-excursion |
| 8962 | (beginning-of-line) | 9001 | (beginning-of-line) |
| 8963 | (while (search-forward "|" pos t) | 9002 | (while (search-forward "|" pos t) |
| 8964 | (unless (markdown--thing-at-wiki-link (match-beginning 0)) | 9003 | (when (and (not (looking-back "\\\\|" (line-beginning-position))) |
| 9004 | (not (markdown--thing-at-wiki-link (match-beginning 0)))) | ||
| 8965 | (setq cnt (1+ cnt))))) | 9005 | (setq cnt (1+ cnt))))) |
| 8966 | cnt)) | 9006 | cnt)) |
| 8967 | 9007 | ||
| @@ -9000,7 +9040,8 @@ table." | |||
| 9000 | (beginning-of-line 1) | 9040 | (beginning-of-line 1) |
| 9001 | (when (> n 0) | 9041 | (when (> n 0) |
| 9002 | (while (and (> n 0) (search-forward "|" (point-at-eol) t)) | 9042 | (while (and (> n 0) (search-forward "|" (point-at-eol) t)) |
| 9003 | (unless (markdown--thing-at-wiki-link (match-beginning 0)) | 9043 | (when (and (not (looking-back "\\\\|" (line-beginning-position))) |
| 9044 | (not (markdown--thing-at-wiki-link (match-beginning 0)))) | ||
| 9004 | (cl-decf n))) | 9045 | (cl-decf n))) |
| 9005 | (if on-delim | 9046 | (if on-delim |
| 9006 | (backward-char 1) | 9047 | (backward-char 1) |
| @@ -9203,7 +9244,8 @@ With optional argument UP, move it up." | |||
| 9203 | (insert "| ")) | 9244 | (insert "| ")) |
| 9204 | (forward-line))) | 9245 | (forward-line))) |
| 9205 | (set-marker end nil) | 9246 | (set-marker end nil) |
| 9206 | (markdown-table-align))) | 9247 | (when markdown-table-align-p |
| 9248 | (markdown-table-align)))) | ||
| 9207 | 9249 | ||
| 9208 | (defun markdown-table-delete-column () | 9250 | (defun markdown-table-delete-column () |
| 9209 | "Delete column at point from table." | 9251 | "Delete column at point from table." |
| @@ -9217,12 +9259,13 @@ With optional argument UP, move it up." | |||
| 9217 | (goto-char begin) | 9259 | (goto-char begin) |
| 9218 | (while (< (point) end) | 9260 | (while (< (point) end) |
| 9219 | (markdown-table-goto-column col t) | 9261 | (markdown-table-goto-column col t) |
| 9220 | (and (looking-at "|[^|\n]+|") | 9262 | (and (looking-at "|\\(?:\\\\|\\|[^|\n]\\)+|") |
| 9221 | (replace-match "|")) | 9263 | (replace-match "|")) |
| 9222 | (forward-line))) | 9264 | (forward-line))) |
| 9223 | (set-marker end nil) | 9265 | (set-marker end nil) |
| 9224 | (markdown-table-goto-column (max 1 (1- col))) | 9266 | (markdown-table-goto-column (max 1 (1- col))) |
| 9225 | (markdown-table-align))) | 9267 | (when markdown-table-align-p |
| 9268 | (markdown-table-align)))) | ||
| 9226 | 9269 | ||
| 9227 | (defun markdown-table-move-column (&optional left) | 9270 | (defun markdown-table-move-column (&optional left) |
| 9228 | "Move table column at point to the right. | 9271 | "Move table column at point to the right. |
| @@ -9243,12 +9286,13 @@ With optional argument LEFT, move it to the left." | |||
| 9243 | (goto-char begin) | 9286 | (goto-char begin) |
| 9244 | (while (< (point) end) | 9287 | (while (< (point) end) |
| 9245 | (markdown-table-goto-column col1 t) | 9288 | (markdown-table-goto-column col1 t) |
| 9246 | (when (looking-at "|\\([^|\n]+\\)|\\([^|\n]+\\)|") | 9289 | (when (looking-at "|\\(\\(?:\\\\|\\|[^|\n]\\|\\)+\\)|\\(\\(?:\\\\|\\|[^|\n]\\|\\)+\\)|") |
| 9247 | (replace-match "|\\2|\\1|")) | 9290 | (replace-match "|\\2|\\1|")) |
| 9248 | (forward-line))) | 9291 | (forward-line))) |
| 9249 | (set-marker end nil) | 9292 | (set-marker end nil) |
| 9250 | (markdown-table-goto-column colpos) | 9293 | (markdown-table-goto-column colpos) |
| 9251 | (markdown-table-align))) | 9294 | (when markdown-table-align-p |
| 9295 | (markdown-table-align)))) | ||
| 9252 | 9296 | ||
| 9253 | (defun markdown-table-move-column-left () | 9297 | (defun markdown-table-move-column-left () |
| 9254 | "Move table column at point to the left." | 9298 | "Move table column at point to the left." |
| @@ -9269,7 +9313,8 @@ Create new table lines if required." | |||
| 9269 | (if (or (looking-at "[ \t]*$") | 9313 | (if (or (looking-at "[ \t]*$") |
| 9270 | (save-excursion (skip-chars-backward " \t") (bolp))) | 9314 | (save-excursion (skip-chars-backward " \t") (bolp))) |
| 9271 | (newline) | 9315 | (newline) |
| 9272 | (markdown-table-align) | 9316 | (when markdown-table-align-p |
| 9317 | (markdown-table-align)) | ||
| 9273 | (let ((col (markdown-table-get-column))) | 9318 | (let ((col (markdown-table-get-column))) |
| 9274 | (beginning-of-line 2) | 9319 | (beginning-of-line 2) |
| 9275 | (if (or (not (markdown-table-at-point-p)) | 9320 | (if (or (not (markdown-table-at-point-p)) |
| @@ -9287,7 +9332,8 @@ Create new table lines if required." | |||
| 9287 | (interactive) | 9332 | (interactive) |
| 9288 | (unless (markdown-table-at-point-p) | 9333 | (unless (markdown-table-at-point-p) |
| 9289 | (user-error "Not at a table")) | 9334 | (user-error "Not at a table")) |
| 9290 | (markdown-table-align) | 9335 | (when markdown-table-align-p |
| 9336 | (markdown-table-align)) | ||
| 9291 | (let ((end (markdown-table-end))) | 9337 | (let ((end (markdown-table-end))) |
| 9292 | (when (markdown-table-hline-at-point-p) (end-of-line 1)) | 9338 | (when (markdown-table-hline-at-point-p) (end-of-line 1)) |
| 9293 | (condition-case nil | 9339 | (condition-case nil |
| @@ -9310,7 +9356,8 @@ Create new table lines if required." | |||
| 9310 | (interactive) | 9356 | (interactive) |
| 9311 | (unless (markdown-table-at-point-p) | 9357 | (unless (markdown-table-at-point-p) |
| 9312 | (user-error "Not at a table")) | 9358 | (user-error "Not at a table")) |
| 9313 | (markdown-table-align) | 9359 | (when markdown-table-align-p |
| 9360 | (markdown-table-align)) | ||
| 9314 | (when (markdown-table-hline-at-point-p) (beginning-of-line 1)) | 9361 | (when (markdown-table-hline-at-point-p) (beginning-of-line 1)) |
| 9315 | (condition-case nil | 9362 | (condition-case nil |
| 9316 | (progn | 9363 | (progn |
| @@ -9366,7 +9413,8 @@ Horizontal separator lines will be eliminated." | |||
| 9366 | contents ""))) | 9413 | contents ""))) |
| 9367 | (markdown-table-goto-dline col_old) | 9414 | (markdown-table-goto-dline col_old) |
| 9368 | (markdown-table-goto-column dline_old)) | 9415 | (markdown-table-goto-column dline_old)) |
| 9369 | (markdown-table-align)) | 9416 | (when markdown-table-align-p |
| 9417 | (markdown-table-align))) | ||
| 9370 | 9418 | ||
| 9371 | (defun markdown-table-sort-lines (&optional sorting-type) | 9419 | (defun markdown-table-sort-lines (&optional sorting-type) |
| 9372 | "Sort table lines according to the column at point. | 9420 | "Sort table lines according to the column at point. |
| @@ -9505,7 +9553,8 @@ spaces, or alternatively a TAB should be used as the separator." | |||
| 9505 | (t (error "Invalid cell separator")))) | 9553 | (t (error "Invalid cell separator")))) |
| 9506 | (while (re-search-forward re end t) (replace-match "| " t t))) | 9554 | (while (re-search-forward re end t) (replace-match "| " t t))) |
| 9507 | (goto-char begin) | 9555 | (goto-char begin) |
| 9508 | (markdown-table-align))) | 9556 | (when markdown-table-align-p |
| 9557 | (markdown-table-align)))) | ||
| 9509 | 9558 | ||
| 9510 | (defun markdown-insert-table (&optional rows columns align) | 9559 | (defun markdown-insert-table (&optional rows columns align) |
| 9511 | "Insert an empty pipe table. | 9560 | "Insert an empty pipe table. |
| @@ -9594,6 +9643,9 @@ rows and columns and the column alignment." | |||
| 9594 | ;;;###autoload | 9643 | ;;;###autoload |
| 9595 | (define-derived-mode markdown-mode text-mode "Markdown" | 9644 | (define-derived-mode markdown-mode text-mode "Markdown" |
| 9596 | "Major mode for editing Markdown files." | 9645 | "Major mode for editing Markdown files." |
| 9646 | (when buffer-read-only | ||
| 9647 | (when (or (not (buffer-file-name)) (file-writable-p (buffer-file-name))) | ||
| 9648 | (setq-local buffer-read-only nil))) | ||
| 9597 | ;; Natural Markdown tab width | 9649 | ;; Natural Markdown tab width |
| 9598 | (setq tab-width 4) | 9650 | (setq tab-width 4) |
| 9599 | ;; Comments | 9651 | ;; Comments |
| @@ -9607,7 +9659,7 @@ rows and columns and the column alignment." | |||
| 9607 | (setq-local sentence-end-base "[.?!…‽][]\"'”’)}»›*_`~]*") | 9659 | (setq-local sentence-end-base "[.?!…‽][]\"'”’)}»›*_`~]*") |
| 9608 | ;; Syntax | 9660 | ;; Syntax |
| 9609 | (add-hook 'syntax-propertize-extend-region-functions | 9661 | (add-hook 'syntax-propertize-extend-region-functions |
| 9610 | #'markdown-syntax-propertize-extend-region) | 9662 | #'markdown-syntax-propertize-extend-region nil t) |
| 9611 | (add-hook 'jit-lock-after-change-extend-region-functions | 9663 | (add-hook 'jit-lock-after-change-extend-region-functions |
| 9612 | #'markdown-font-lock-extend-region-function t t) | 9664 | #'markdown-font-lock-extend-region-function t t) |
| 9613 | (setq-local syntax-propertize-function #'markdown-syntax-propertize) | 9665 | (setq-local syntax-propertize-function #'markdown-syntax-propertize) |
| @@ -9746,7 +9798,7 @@ rows and columns and the column alignment." | |||
| 9746 | "Major mode for editing GitHub Flavored Markdown files." | 9798 | "Major mode for editing GitHub Flavored Markdown files." |
| 9747 | (setq markdown-link-space-sub-char "-") | 9799 | (setq markdown-link-space-sub-char "-") |
| 9748 | (setq markdown-wiki-link-search-subdirectories t) | 9800 | (setq markdown-wiki-link-search-subdirectories t) |
| 9749 | (setq-local markdown-table-at-point-p-function 'gfm--table-at-point-p) | 9801 | (setq-local markdown-table-at-point-p-function #'gfm--table-at-point-p) |
| 9750 | (add-hook 'post-self-insert-hook #'gfm--electric-pair-fence-code-block 'append t) | 9802 | (add-hook 'post-self-insert-hook #'gfm--electric-pair-fence-code-block 'append t) |
| 9751 | (markdown-gfm-parse-buffer-for-languages)) | 9803 | (markdown-gfm-parse-buffer-for-languages)) |
| 9752 | 9804 | ||
| @@ -9757,7 +9809,7 @@ rows and columns and the column alignment." | |||
| 9757 | "Enable hidden markup mode in `markdown-view-mode' and `gfm-view-mode'." | 9809 | "Enable hidden markup mode in `markdown-view-mode' and `gfm-view-mode'." |
| 9758 | :group 'markdown | 9810 | :group 'markdown |
| 9759 | :type 'boolean | 9811 | :type 'boolean |
| 9760 | :safe 'booleanp) | 9812 | :safe #'booleanp) |
| 9761 | 9813 | ||
| 9762 | (defvar markdown-view-mode-map | 9814 | (defvar markdown-view-mode-map |
| 9763 | (let ((map (make-sparse-keymap))) | 9815 | (let ((map (make-sparse-keymap))) |
diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 91db316..9d619d5 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el | |||
| @@ -484,6 +484,10 @@ this will do usual adaptive fill behaviors." | |||
| 484 | ;;;###autoload | 484 | ;;;###autoload |
| 485 | (add-to-list 'auto-mode-alist '("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode)) | 485 | (add-to-list 'auto-mode-alist '("\\.\\(e?ya?\\|ra\\)ml\\'" . yaml-mode)) |
| 486 | 486 | ||
| 487 | ;;;###autoload | ||
| 488 | (add-to-list 'magic-mode-alist | ||
| 489 | '("^%YAML\\s-+[0-9]+\\.[0-9]+\\(\\s-+#\\|\\s-*$\\)" . yaml-mode)) | ||
| 490 | |||
| 487 | (provide 'yaml-mode) | 491 | (provide 'yaml-mode) |
| 488 | 492 | ||
| 489 | ;;; yaml-mode.el ends here | 493 | ;;; yaml-mode.el ends here |
