From 7a3b877abecb9b2f8ee1200bd2617202b325acd1 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Sat, 20 Feb 2021 21:03:18 +0100 Subject: Update markdown-mode and remove / cleanup some Python snippets --- .emacs.d/lisp/markdown-mode.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to '.emacs.d/lisp') diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 9522da4..6775bfa 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -92,7 +92,7 @@ Any changes to the output buffer made by this hook will be saved.") :group 'text :link '(url-link "https://jblevins.org/projects/markdown-mode/")) -(defcustom markdown-command (let ((command (cl-loop for cmd in '("markdown" "pandoc") +(defcustom markdown-command (let ((command (cl-loop for cmd in '("markdown" "pandoc" "markdown_py") when (executable-find cmd) return (file-name-nondirectory it)))) (or command "markdown")) @@ -9297,15 +9297,23 @@ Create new table lines if required." (unless (markdown-table-at-point-p) (user-error "Not at a table")) (markdown-table-align) - (when (markdown-table-hline-at-point-p) (end-of-line 1)) + (when (markdown-table-hline-at-point-p) (beginning-of-line 1)) (condition-case nil (progn (re-search-backward "\\(?:^\\|[^\\]\\)|" (markdown-table-begin)) + ;; When this function is called while in the first cell in a + ;; table, the point will now be at the beginning of a line. In + ;; this case, we need to move past one additional table + ;; boundary, the end of the table on the previous line. + (when (= (point) (line-beginning-position)) + (re-search-backward "\\(?:^\\|[^\\]\\)|" (markdown-table-begin))) (re-search-backward "\\(?:^\\|[^\\]\\)|" (markdown-table-begin))) (error (user-error "Cannot move to previous table cell"))) - (while (looking-at "|\\([-:]\\|[ \t]*$\\)") - (re-search-backward "\\(?:^\\|[^\\]\\)|" (markdown-table-begin))) - (when (looking-at "| ?") (goto-char (match-end 0)))) + (when (looking-at "\\(?:^\\|[^\\]\\)| ?") (goto-char (match-end 0))) + + ;; This may have dropped point on the hline. + (when (markdown-table-hline-at-point-p) + (markdown-table-backward-cell))) (defun markdown-table-transpose () "Transpose table at point. -- cgit v1.3