[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode c6f63dea9e 2/5: Implement drag and drop hand
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode c6f63dea9e 2/5: Implement drag and drop handler |
Date: |
Sat, 28 Oct 2023 07:01:38 -0400 (EDT) |
branch: elpa/markdown-mode
commit c6f63dea9e2cb0271bf6749caa8dae7191aca1db
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>
Implement drag and drop handler
---
markdown-mode.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/markdown-mode.el b/markdown-mode.el
index cb328c8280..fff607834b 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -9870,6 +9870,14 @@ rows and columns and the column alignment."
(insert " "))
(setq files (cdr files))))))
+(defun markdown--dnd-local-file-handler (url _action)
+ (require 'mailcap)
+ (let* ((filename (dnd-get-local-file-name url))
+ (file (file-relative-name filename)))
+ (when (string-match-p "\\s-" file)
+ (setq file (concat "<" file ">")))
+ (markdown-insert-inline-image "link text" file)))
+
;;; Mode Definition ==========================================================
@@ -9998,10 +10006,14 @@ rows and columns and the column alignment."
(add-hook 'electric-quote-inhibit-functions
#'markdown--inhibit-electric-quote nil :local)
+ ;; drag and drop handler
+ (setq-local dnd-protocol-alist (cons '("^file:///" .
markdown--dnd-local-file-handler)
+ dnd-protocol-alist))
+
;; media handler
(when (version< "29" emacs-version)
(yank-media-handler "image/.*" #'markdown--image-media-handler)
- ;; TODO other than GNOME support, like KDE etc
+ ;; TODO support other than GNOME, like KDE etc
(yank-media-handler "x-special/gnome-copied-files"
#'markdown--file-media-handler))
;; Make checkboxes buttons