branch: elpa/markdown-mode commit 244464388d8e34acdd8becca06168711f59a6fd6 Merge: f579bcc561 d2d960bec1 Author: Joe Reinhart <joseph.reinh...@gmail.com> Commit: Joe Reinhart <joseph.reinh...@gmail.com>
Merge branch 'master' into jayemar/toggle-hiding-of-wiki-links --- .../01_bug_report.md} | 16 +++-- .github/ISSUE_TEMPLATE/02_performance_issue.md | 29 +++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + CHANGES.md | 7 ++ markdown-mode.el | 76 ++++++++++++++++------ 5 files changed, 103 insertions(+), 26 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/01_bug_report.md similarity index 88% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/01_bug_report.md index 92dbb96ed4..a462ff4401 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/01_bug_report.md @@ -1,3 +1,9 @@ +--- +name: Bug report +about: Report a bug +title: '' +--- + <!--- Provide a general summary of the issue in the Title above --> ## Expected Behavior @@ -43,10 +49,10 @@ Markdown Mode and Emacs version numbers. Examples: - Markdown Mode: From Git on 2017-10-17, 2.4-dev, or 2.3 -- Emacs: 25.3.2 -- OS: macOS High Sierra +- Emacs: 30.1 +- OS: macOS Sequoia --> -- Markdown Mode: -- Emacs: -- OS: +- Markdown Mode: +- Emacs: +- OS: diff --git a/.github/ISSUE_TEMPLATE/02_performance_issue.md b/.github/ISSUE_TEMPLATE/02_performance_issue.md new file mode 100644 index 0000000000..678f92a115 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/02_performance_issue.md @@ -0,0 +1,29 @@ +--- +name: Performance issue +about: Report a performance problem or regression +title: '' +--- + +### Description + +<!-- +What is the issue ? Regression ? +When does markdown-mode become slow ? syntax, file size etc +--> + +## Software Versions + +<!-- +Use M-x markdown-show-version and M-x emacs-version to determine the +Markdown Mode and Emacs version numbers. + +Examples: + +- Markdown Mode: From Git on 2017-10-17, 2.8-dev, or 2.7 +- Emacs: 30.1 +- OS: macOS Sequoia +--> + +- Markdown Mode: +- Emacs: +- OS: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..3ba13e0cec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/CHANGES.md b/CHANGES.md index d3f62d0890..b4171603c5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,12 +6,19 @@ - GNU Emacs 28.1 or later is required. * New Features: + - Introduce `markdown-yank-dnd-method` what action to perform on the dropped files + like `org-mode`. * Bug fixes: + - `markdown-export` should not output stderr content to output file * Improvements: - Support drag and drop features on Windows and multiple files' drag and drop - Added cmark and cmark-gfm to the markdown command list. + - Disable `imenu-submenus-on-top` by default [GH-882][] + + [gh-882]: https://github.com/jrblevin/markdown-mode/issues/882 + [gh-891]: https://github.com/jrblevin/markdown-mode/issues/891 # Markdown Mode 2.7 diff --git a/markdown-mode.el b/markdown-mode.el index 765ef7b499..d2094f2647 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -53,6 +53,7 @@ (declare-function sh-set-shell "sh-script") (declare-function mailcap-file-name-to-mime-type "mailcap") (declare-function dnd-get-local-file-name "dnd") +(declare-function dnd-open-local-file "dnd") ;; for older emacs<29 (declare-function mailcap-mime-type-to-extension "mailcap") @@ -705,6 +706,20 @@ This may also be a cons cell where the behavior for `C-a' and (const :tag "on: before closing tags first" t) (const :tag "reversed: after closing tags first" reversed)))) :package-version '(markdown-mode . "2.7")) + +(defcustom markdown-yank-dnd-method 'file-link + "Action to perform on the dropped files. +When the value is the symbol, + - `copy-and-insert' -- copy file in current directory and insert its link + - `open' -- open dropped file in Emacs + - `insert-link' -- insert link of dropped/pasted file + - `ask' -- ask what to do out of the above." + :group 'markdown + :package-version '(markdown-mode "2.8") + :type '(choice (const :tag "Copy and insert" copy-and-insert) + (const :tag "Open file" open) + (const :tag "Insert file link" file-link) + (const :tag "Ask what to do" ask))) ;;; Markdown-Specific `rx' Macro ============================================== @@ -7726,8 +7741,8 @@ Return the name of the output buffer used." (erase-buffer)) (if (stringp command) (if (not (null command-args)) - (apply #'call-process-region begin-region end-region command nil buf nil command-args) - (call-process-region begin-region end-region command nil buf)) + (apply #'call-process-region begin-region end-region command nil (list buf nil) nil command-args) + (call-process-region begin-region end-region command nil (list buf nil))) (if markdown-command-needs-filename (if (not buffer-file-name) (user-error "Must be visiting a file") @@ -9973,12 +9988,8 @@ indicate that sorting should be done in reverse order." (t 1)))) (sorting-type (or sorting-type - (progn - ;; workaround #641 - ;; Emacs < 28 hides prompt message by another message. This erases it. - (message "") - (read-char-exclusive - "Sort type: [a]lpha [n]umeric (A/N means reversed): "))))) + (read-char-exclusive + "Sort type: [a]lpha [n]umeric (A/N means reversed): ")))) (save-restriction ;; Narrow buffer to appropriate sorting area (if (region-active-p) @@ -10207,18 +10218,41 @@ rows and columns and the column alignment." (insert " ")) (setq files (cdr files)))))) -(defun markdown--dnd-local-file-handler (url _action) +(defun markdown--dnd-read-method () + (let ((choice (read-multiple-choice "What to do with file?" + '((?c "copy and insert") + (?o "open") + (?i "insert link"))))) + (cl-case (car choice) + (?c 'copy-and-insert) + (?o 'open) + (?i 'insert) + (otherwise (markdown--dnd-read-method))))) + +(defun markdown--dnd-insert-path (filename) + (let ((mimetype (mailcap-file-name-to-mime-type filename)) + (link-text "link text")) + (when (string-match-p "\\s-" filename) + (setq filename (concat "<" filename ">"))) + (if (string-prefix-p "image/" mimetype) + (markdown-insert-inline-image link-text filename) + (markdown-insert-inline-link link-text filename)))) + +(defun markdown--dnd-local-file-handler (url action) (require 'mailcap) (require 'dnd) (let* ((filename (dnd-get-local-file-name url)) - (mimetype (mailcap-file-name-to-mime-type filename)) - (file (file-relative-name filename)) - (link-text "link text")) - (when (string-match-p "\\s-" file) - (setq file (concat "<" file ">"))) - (if (string-prefix-p "image/" mimetype) - (markdown-insert-inline-image link-text file) - (markdown-insert-inline-link link-text file)))) + (method (if (eq markdown-yank-dnd-method 'ask) + (markdown--dnd-read-method) + markdown-yank-dnd-method))) + (cl-case method + (copy-and-insert + (let ((copied (expand-file-name (file-name-nondirectory filename)))) + (copy-file filename copied) + (markdown--dnd-insert-path (file-relative-name copied)))) + (open + (dnd-open-local-file url action)) + (insert (markdown--dnd-insert-path (file-relative-name filename)))))) (defun markdown--dnd-multi-local-file-handler (urls action) (let ((multile-urls-p (> (length urls) 1))) @@ -10283,10 +10317,10 @@ rows and columns and the column alignment." ;; Add a buffer-local hook to reload after file-local variables are read (add-hook 'hack-local-variables-hook #'markdown-handle-local-variables nil t) ;; For imenu support - (setq imenu-create-index-function - (if markdown-nested-imenu-heading-index - #'markdown-imenu-create-nested-index - #'markdown-imenu-create-flat-index)) + (setq-local imenu-create-index-function (if markdown-nested-imenu-heading-index + #'markdown-imenu-create-nested-index + #'markdown-imenu-create-flat-index) + imenu-submenus-on-top nil) ;; Defun movement (setq-local beginning-of-defun-function #'markdown-beginning-of-defun)