mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Improve 'context-menu-send-to' (bug#79512)
* lisp/mouse.el (context-menu-functions): Add missing 'context-menu-send-to' to :type. (context-menu-send-to): Get non-nil items to avoid useless message "Nothing to send". * lisp/send-to.el (send-to-handlers): Change from 'defvar-local' to 'defvar' to allow easier global configuration. (send-to-supported-p): Check for non-nil handler.
This commit is contained in:
parent
0649c501ad
commit
c9078c505b
2 changed files with 18 additions and 11 deletions
|
|
@ -407,6 +407,7 @@ and should return the same menu with changes such as added new menu items."
|
|||
(function-item context-menu-global)
|
||||
(function-item context-menu-local)
|
||||
(function-item context-menu-minor)
|
||||
(function-item context-menu-send-to)
|
||||
(function-item context-menu-buffers)
|
||||
(function-item context-menu-project)
|
||||
(function-item context-menu-vc)
|
||||
|
|
@ -541,12 +542,16 @@ Some context functions add menu items below the separator."
|
|||
(defun context-menu-send-to (menu _click)
|
||||
"Add a \"Send to...\" context MENU entry on supported platforms."
|
||||
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
|
||||
(when (send-to-supported-p)
|
||||
(when-let* ((_ (send-to-supported-p))
|
||||
(handler (send-to--resolve-handler))
|
||||
(collect (map-elt handler :collect))
|
||||
(items (funcall collect)))
|
||||
(define-key-after menu [separator-send] menu-bar-separator)
|
||||
(define-key-after menu [send]
|
||||
'(menu-item "Send to..." (lambda ()
|
||||
(interactive)
|
||||
(send-to))
|
||||
`(menu-item "Send to..."
|
||||
,(lambda ()
|
||||
(interactive)
|
||||
(send-to items))
|
||||
:help
|
||||
"Send item (region, buffer file, or Dired files) to applications or service")))
|
||||
menu)
|
||||
|
|
|
|||
|
|
@ -47,12 +47,13 @@
|
|||
:group 'external
|
||||
:version "31.1")
|
||||
|
||||
(defvar-local send-to-handlers '(((:supported . send-to--ns-supported-p)
|
||||
(:collect . send-to--collect-items)
|
||||
(:send . send-to--ns-send-items))
|
||||
((:supported . send-to--open-externally-supported-p)
|
||||
(:collect . send-to--collect-items)
|
||||
(:send . send-to--open-externally)))
|
||||
(defvar send-to-handlers
|
||||
'(((:supported . send-to--ns-supported-p)
|
||||
(:collect . send-to--collect-items)
|
||||
(:send . send-to--ns-send-items))
|
||||
((:supported . send-to--open-externally-supported-p)
|
||||
(:collect . send-to--collect-items)
|
||||
(:send . send-to--open-externally)))
|
||||
"A list of handlers that may be able to send files to applications or services.
|
||||
|
||||
Sending is handled by the first supported handler from `send-to-handlers' whose
|
||||
|
|
@ -82,7 +83,8 @@ paths known to exist. In these instances, files will be sent instead.\"
|
|||
;;;###autoload
|
||||
(defun send-to-supported-p ()
|
||||
"Return non-nil for platforms where `send-to' is supported."
|
||||
(funcall (map-elt (send-to--resolve-handler) :supported)))
|
||||
(when-let* ((handler (send-to--resolve-handler)))
|
||||
(funcall (map-elt handler :supported))))
|
||||
|
||||
;;;###autoload
|
||||
(defun send-to (&optional items)
|
||||
|
|
|
|||
Loading…
Reference in a new issue