summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2023-04-15 12:43:37 -0400
committerEli Zaretskii <eliz@gnu.org>2023-04-15 12:43:37 -0400
commit5fecdbcd81db3d4a06277400c458d8ca7dcf7462 (patch)
treee8a6e1cca4f6f7642a268575ecf5243347a87ee8 /lisp
parent4c086bf2951596d04677c343eb49fb32a3831e18 (diff)
parent5ef7ff05736b9d1b4d806cfe04ec5d99c090e748 (diff)
downloademacs-5fecdbcd81db3d4a06277400c458d8ca7dcf7462.tar.gz
Merge from origin/emacs-29
5ef7ff05736 ; Start a new ChangeLog.4 file. 11126c6d30a Fix 'C-h k' for "Paste from Kill Menu" in context menus 74ddfe811f9 ; * doc/misc/calc.texi (Rewrites Tutorial): Fix a typo (b... 08cda286c3f Improve the documentation of the XDS support 14d1c00e806 Allow reindentation of images inserted by 'mm-inline-image' b63a9eda01c Fix "C-h k" and "C-h c" with Paste from Kill Menu b36c21e27dc Change cursor color on NS port when it matches the face b... 96714c106b7 Improve documentation of image-related commands 6a2863ca016 Fix handling of sliced images 5be79fd05a5 ; * etc/NEWS: Announce 'cyrillic-mongolian' IM. ca1a0fda98a ; Fix last change. ce63462dbda Add cyrillic-mongolian input method 58801792706 ; Minor addition to the Emacs FAQ 88847dee125 Jsonrpc: don't bind inhibit-read-only to t so early cb8c87a423a Allow active region when IM is used # Conflicts: # etc/NEWS
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gnus/mm-view.el2
-rw-r--r--lisp/image.el25
-rw-r--r--lisp/image/image-crop.el59
-rw-r--r--lisp/international/quail.el3
-rw-r--r--lisp/jsonrpc.el8
-rw-r--r--lisp/leim/quail/cyrillic.el119
-rw-r--r--lisp/mouse.el3
-rw-r--r--lisp/subr.el74
-rw-r--r--lisp/x-dnd.el120
9 files changed, 296 insertions, 117 deletions
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 8dfb0deb418..2c407353559 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -98,7 +98,7 @@ This is only used if `mm-inline-large-images' is set to
(truncate (* mm-inline-large-images-proportion
(- (nth 3 edges) (nth 1 edges)))))))
image))
- " ")
+ "x")
(insert "\n")
(mm-handle-set-undisplayer
handle
diff --git a/lisp/image.el b/lisp/image.el
index 838cc0f8942..a32ff1a35bb 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -172,22 +172,27 @@ or \"ffmpeg\") is installed."
(define-error 'unknown-image-type "Unknown image type")
-(defvar-keymap image-map
- :doc "Map put into text properties on images."
+(defvar-keymap image-slice-map
+ :doc "Map put into text properties on sliced images."
"i" (define-keymap
"-" #'image-decrease-size
"+" #'image-increase-size
- "r" #'image-rotate
"o" #'image-save
"c" #'image-crop
- "x" #'image-cut
- "h" #'image-flip-horizontally
- "v" #'image-flip-vertically)
+ "x" #'image-cut)
"C-<wheel-down>" #'image-mouse-decrease-size
"C-<mouse-5>" #'image-mouse-decrease-size
"C-<wheel-up>" #'image-mouse-increase-size
"C-<mouse-4>" #'image-mouse-increase-size)
+(defvar-keymap image-map
+ :doc "Map put into text properties on images."
+ :parent image-slice-map
+ "i" (define-keymap
+ "r" #'image-rotate
+ "h" #'image-flip-horizontally
+ "v" #'image-flip-vertically))
+
(defun image-load-path-for-library (library image &optional path no-error)
"Return a suitable search path for images used by LIBRARY.
@@ -665,7 +670,9 @@ is non-nil, this is inhibited."
image)
rear-nonsticky t
inhibit-isearch ,inhibit-isearch
- keymap ,image-map))))
+ keymap ,(if slice
+ image-slice-map
+ image-map)))))
;;;###autoload
@@ -701,8 +708,8 @@ The image is automatically split into ROWS x COLS slices."
(insert string)
(add-text-properties start (point)
`(display ,(list (list 'slice x y dx dy) image)
- rear-nonsticky (display)
- keymap ,image-map))
+ rear-nonsticky (display keymap)
+ keymap ,image-slice-map))
(setq x (+ x dx))))
(setq x 0.0
y (+ y dy))
diff --git a/lisp/image/image-crop.el b/lisp/image/image-crop.el
index be6e22bc606..9ef848c5bc8 100644
--- a/lisp/image/image-crop.el
+++ b/lisp/image/image-crop.el
@@ -35,6 +35,7 @@
(declare-function image-property "image.el" (image property))
(declare-function image-size "image.c" (spec &optional pixels frame))
(declare-function imagep "image.c" (spec))
+(declare-function image--get-image "image.el" (&optional position))
(defgroup image-crop ()
"Image cropping."
@@ -113,18 +114,36 @@ and the cropped image data.")
(defun image-cut (&optional color)
"Cut a rectangle from the image under point, filling it with COLOR.
COLOR defaults to the value of `image-cut-color'.
-Interactively, with prefix argument, prompt for COLOR to use."
- (interactive (list (and current-prefix-arg (read-color "Use color: "))))
+Interactively, with prefix argument, prompt for COLOR to use.
+
+This command presents the image with a rectangular area superimposed
+on it, and allows moving and resizing the area to define which
+part of it to cut.
+
+While moving/resizing the cutting area, the following key bindings
+are available:
+
+`q': Exit without changing anything.
+`RET': Crop/cut the image.
+`m': Make mouse movements move the rectangle instead of altering the
+ rectangle shape.
+`s': Same as `m', but make the rectangle into a square first.
+
+After cutting the image, you can save it by `M-x image-save' or
+\\<image-map>\\[image-save] when point is over the image."
+ (interactive (list (and current-prefix-arg
+ (read-color "Color to use for filling: "))))
(image-crop (if (zerop (length color)) image-cut-color color)))
;;;###autoload
(defun image-crop (&optional cut)
"Crop the image under point.
-If CUT is non-nil, remove a rectangle from the image instead of
-cropping the image. In that case CUT should be the name of a
-color to fill the rectangle.
+This command presents the image with a rectangular area superimposed
+on it, and allows moving and resizing the area to define which
+part of it to crop.
-While cropping the image, the following key bindings are available:
+While moving/resizing the cropping area, the following key bindings
+are available:
`q': Exit without changing anything.
`RET': Crop/cut the image.
@@ -132,15 +151,29 @@ While cropping the image, the following key bindings are available:
rectangle shape.
`s': Same as `m', but make the rectangle into a square first.
-After cropping an image, you can save it by `M-x image-save' or
-\\<image-map>\\[image-save] when point is over the image."
+After cropping the image, you can save it by `M-x image-save' or
+\\<image-map>\\[image-save] when point is over the image.
+
+When called from Lisp, if CUT is non-nil, remove a rectangle from
+the image instead of cropping the image. In that case, CUT should
+be the name of a color to fill the rectangle."
(interactive)
(unless (image-type-available-p 'svg)
- (error "SVG support is needed to crop images"))
- (unless (executable-find (car image-crop-crop-command))
- (error "Couldn't find %s command to crop the image"
- (car image-crop-crop-command)))
- (let ((image (get-text-property (point) 'display)))
+ (error "SVG support is needed to crop and cut images"))
+ (let* ((crop-cmd (car image-crop-crop-command))
+ (found (executable-find crop-cmd)))
+ (unless found
+ (error "Couldn't find `%s' command to crop/cut the image" crop-cmd))
+ (if (and (memq system-type '(windows-nt ms-dos))
+ ;; MS-Windows has an incompatible convert.exe, used to
+ ;; convert filesystems...
+ (string-equal crop-cmd "convert")
+ (= 0 (string-search "Invalid drive specification."
+ (shell-command-to-string
+ (format "%s %s" crop-cmd null-device)))))
+ (error "The program `%s' is not an image conversion program"
+ found)))
+ (let ((image (image--get-image)))
(unless (imagep image)
(user-error "No image under point"))
(when (overlays-at (point))
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index 2ffe3392335..317ea8495de 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -1995,7 +1995,8 @@ Remaining args are for FUNC."
(defun quail-minibuffer-message (string)
(message nil)
(let ((point-max (point-max))
- (inhibit-quit t))
+ (inhibit-quit t)
+ (deactivate-mark nil))
(save-excursion
(goto-char point-max)
(insert string))
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 3965d38bc3e..ccf0f966574 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -574,15 +574,14 @@ With optional CLEANUP, kill any associated buffers."
(cl-return-from jsonrpc--process-filter))
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
- (let* ((inhibit-read-only t)
- (jsonrpc--in-process-filter t)
+ (let* ((jsonrpc--in-process-filter t)
(connection (process-get proc 'jsonrpc-connection))
(expected-bytes (jsonrpc--expected-bytes connection)))
;; Insert the text, advancing the process marker.
;;
(save-excursion
(goto-char (process-mark proc))
- (insert string)
+ (let ((inhibit-read-only t)) (insert string))
(set-marker (process-mark proc) (point)))
;; Loop (more than one message might have arrived)
;;
@@ -631,7 +630,8 @@ With optional CLEANUP, kill any associated buffers."
(jsonrpc-connection-receive connection
json-message)))))
(goto-char message-end)
- (delete-region (point-min) (point))
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point)))
(setq expected-bytes nil))))
(t
;; Message is still incomplete
diff --git a/lisp/leim/quail/cyrillic.el b/lisp/leim/quail/cyrillic.el
index ba0b9c9ca12..d0874124fc7 100644
--- a/lisp/leim/quail/cyrillic.el
+++ b/lisp/leim/quail/cyrillic.el
@@ -1844,6 +1844,125 @@ Doubling the postfix separates the letter and postfix
("E**" ["У*"])
("e**" ["у*"]))
+
+;; Mongolian layout: Mongolian alphabet has 2 letters: Ө Ү,
+;; and the layout is quite different from other cyrillic layouts.
+;; Written by Garid Zorigoo.
+(quail-define-package
+ "cyrillic-mongolian" "Mongolian" "MN-" t
+ "Input method for cyrillic Mongolian"
+ nil t nil nil nil nil nil nil nil nil t)
+
+;; № - " ₮ : . _ , % ? е щ
+;; Ф Ц У Ж Э Н Г Ш Ү З К Ъ
+;; Й Ы Б Ө А Х Р О Л Д П
+;; Я Ч Ё С М И Т Ь В Ю
+
+
+(quail-define-rules
+ ;; (lowercase 1st row)
+ ("q" ?ф)
+ ("w" ?ц)
+ ("e" ?у)
+ ("r" ?ж)
+ ("t" ?э)
+ ("y" ?н)
+ ("u" ?г)
+ ("i" ?ш)
+ ("o" ?ү)
+ ("p" ?з)
+ ("[" ?к)
+ ("]" ?ъ)
+ ;; (lowercase 2nd row)
+ ("a" ?й)
+ ("s" ?ы)
+ ("d" ?б)
+ ("f" ?ө)
+ ("g" ?а)
+ ("h" ?х)
+ ("j" ?р)
+ ("k" ?о)
+ ("l" ?л)
+ (";" ?д)
+ ("'" ?п)
+ ;; (lowercase 3rd row)
+ ("z" ?я)
+ ("x" ?ч)
+ ("c" ?ё)
+ ("v" ?с)
+ ("b" ?м)
+ ("n" ?и)
+ ("m" ?т)
+ ("," ?ь)
+ ("." ?в)
+ ("/" ?ю)
+
+
+ ;; (uppercase 1st row)
+ ("Q" ?Ф)
+ ("W" ?Ц)
+ ("E" ?У)
+ ("R" ?Ж)
+ ("T" ?Э)
+ ("Y" ?Н)
+ ("U" ?Г)
+ ("I" ?Ш)
+ ("O" ?Ү)
+ ("P" ?З)
+ ("{" ?К)
+ ("}" ?Ъ)
+ ;; (uppercase 2nd row)
+ ("A" ?Й)
+ ("S" ?Ы)
+ ("D" ?Б)
+ ("F" ?Ө)
+ ("G" ?А)
+ ("H" ?Х)
+ ("J" ?Р)
+ ("K" ?О)
+ ("L" ?Л)
+ (":" ?Д)
+ ("\"" ?П)
+ ;; (uppercase 3rd row)
+ ("Z" ?Я)
+ ("X" ?Ч)
+ ("C" ?Ё)
+ ("V" ?С)
+ ("B" ?М)
+ ("N" ?И)
+ ("M" ?Т)
+ ("<" ?Ь)
+ (">" ?В)
+ ("?" ?Ю)
+
+
+ ;; (number row without shift)
+ ("1" ?№)
+ ("2" ?-)
+ ("3" ?\")
+ ("4" ?₮)
+ ("5" ?:)
+ ("6" ?.)
+ ("7" ?_)
+ ("8" ?,)
+ ("9" ?%)
+ ("0" ??)
+ ("-" ?е)
+ ("=" ?щ)
+ ;; (number row with shift)
+ ("!" ?1)
+ ("@" ?2)
+ ("#" ?3)
+ ("$" ?4)
+ ("%" ?5)
+ ("^" ?6)
+ ("&" ?7)
+ ("*" ?8)
+ ("(" ?9)
+ (")" ?0)
+ ("_" ?Е)
+ ("+" ?Щ))
+
;; Local Variables:
;; coding: utf-8
;; End:
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 9c1a72bb368..3c30361ad7d 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -533,7 +533,8 @@ Some context functions add menu items below the separator."
(i 0))
(dolist (item (reverse yank-menu))
(when (consp item)
- (define-key submenu (vector (setq i (1+ i)))
+ (define-key submenu
+ (vector (intern (format "kill-%d" (setq i (1+ i)))))
`(menu-item ,(cadr item)
,(lambda () (interactive)
(mouse-yank-from-menu click (car item)))))))
diff --git a/lisp/subr.el b/lisp/subr.el
index f90026534e8..a7a67c570b6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1555,31 +1555,32 @@ EVENT may be an event or an event type. If EVENT is a symbol
that has never been used in an event that has been read as input
in the current Emacs session, then this function may fail to include
the `click' modifier."
- (let ((type event))
- (if (listp type)
- (setq type (car type)))
- (if (symbolp type)
- ;; Don't read event-symbol-elements directly since we're not
- ;; sure the symbol has already been parsed.
- (cdr (internal-event-symbol-parse-modifiers type))
- (let ((list nil)
- (char (logand type (lognot (logior ?\M-\0 ?\C-\0 ?\S-\0
- ?\H-\0 ?\s-\0 ?\A-\0)))))
- (if (not (zerop (logand type ?\M-\0)))
- (push 'meta list))
- (if (or (not (zerop (logand type ?\C-\0)))
- (< char 32))
- (push 'control list))
- (if (or (not (zerop (logand type ?\S-\0)))
- (/= char (downcase char)))
- (push 'shift list))
- (or (zerop (logand type ?\H-\0))
- (push 'hyper list))
- (or (zerop (logand type ?\s-\0))
- (push 'super list))
- (or (zerop (logand type ?\A-\0))
- (push 'alt list))
- list))))
+ (unless (stringp event)
+ (let ((type event))
+ (if (listp type)
+ (setq type (car type)))
+ (if (symbolp type)
+ ;; Don't read event-symbol-elements directly since we're not
+ ;; sure the symbol has already been parsed.
+ (cdr (internal-event-symbol-parse-modifiers type))
+ (let ((list nil)
+ (char (logand type (lognot (logior ?\M-\0 ?\C-\0 ?\S-\0
+ ?\H-\0 ?\s-\0 ?\A-\0)))))
+ (if (not (zerop (logand type ?\M-\0)))
+ (push 'meta list))
+ (if (or (not (zerop (logand type ?\C-\0)))
+ (< char 32))
+ (push 'control list))
+ (if (or (not (zerop (logand type ?\S-\0)))
+ (/= char (downcase char)))
+ (push 'shift list))
+ (or (zerop (logand type ?\H-\0))
+ (push 'hyper list))
+ (or (zerop (logand type ?\s-\0))
+ (push 'super list))
+ (or (zerop (logand type ?\A-\0))
+ (push 'alt list))
+ list)))))
(defun event-basic-type (event)
"Return the basic type of the given event (all modifiers removed).
@@ -1587,17 +1588,18 @@ The value is a printing character (not upper case) or a symbol.
EVENT may be an event or an event type. If EVENT is a symbol
that has never been used in an event that has been read as input
in the current Emacs session, then this function may return nil."
- (if (consp event)
- (setq event (car event)))
- (if (symbolp event)
- (car (get event 'event-symbol-elements))
- (let* ((base (logand event (1- ?\A-\0)))
- (uncontrolled (if (< base 32) (logior base 64) base)))
- ;; There are some numbers that are invalid characters and
- ;; cause `downcase' to get an error.
- (condition-case ()
- (downcase uncontrolled)
- (error uncontrolled)))))
+ (unless (stringp event)
+ (if (consp event)
+ (setq event (car event)))
+ (if (symbolp event)
+ (car (get event 'event-symbol-elements))
+ (let* ((base (logand event (1- ?\A-\0)))
+ (uncontrolled (if (< base 32) (logior base 64) base)))
+ ;; There are some numbers that are invalid characters and
+ ;; cause `downcase' to get an error.
+ (condition-case ()
+ (downcase uncontrolled)
+ (error uncontrolled))))))
(defsubst mouse-movement-p (object)
"Return non-nil if OBJECT is a mouse movement event."
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index b213b155249..9286a1858cf 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -34,20 +34,20 @@
;;; Customizable variables
(defcustom x-dnd-test-function #'x-dnd-default-test-function
- "The function drag and drop uses to determine if to accept or reject a drop.
-The function takes three arguments, WINDOW, ACTION and TYPES.
-WINDOW is where the mouse is when the function is called. WINDOW
-may be a frame if the mouse isn't over a real window (i.e. menu
-bar, tool bar or scroll bar). ACTION is the suggested action
-from the drag and drop source, one of the symbols move, copy,
-link or ask. TYPES is a vector of available types for the drop.
-
-Each element of TYPE should either be a string (containing the
+ "Function to be used by drag-and-drop to determine whether to accept a drop.
+The function takes three arguments: WINDOW, ACTION, and TYPES.
+WINDOW is where the window under the mouse is when the function is called.
+WINDOW may be a frame if the mouse isn't over a real window (e.g., menu
+bar, tool bar, scroll bar, etc.).
+ACTION is the suggested action from the drag and drop source, one of the
+symbols `move', `copy', `link' or `ask'.
+TYPES is a vector of available types for the drop.
+Each element of TYPES should either be a string (containing the
name of the type's X atom), or a symbol, whose name will be used.
The function shall return nil to reject the drop or a cons with
-two values, the wanted action as car and the wanted type as cdr.
-The wanted action can be copy, move, link, ask or private.
+two values, the wanted action as `car' and the wanted type as `cdr'.
+The wanted action can be `copy', `move', `link', `ask' or `private'.
The default value for this variable is `x-dnd-default-test-function'."
:version "22.1"
@@ -70,14 +70,18 @@ The default value for this variable is `x-dnd-default-test-function'."
(,(purecopy "DndTypeFile") . x-dnd-handle-offix-file)
(,(purecopy "DndTypeFiles") . x-dnd-handle-offix-files)
(,(purecopy "DndTypeText") . dnd-insert-text))
- "Which function to call to handle a drop of that type.
-If the type for the drop is not present, or the function is nil,
-the drop is rejected. The function takes three arguments, WINDOW, ACTION
-and DATA. WINDOW is where the drop occurred, ACTION is the action for
-this drop (copy, move, link, private or ask) as determined by a previous
-call to `x-dnd-test-function'. DATA is the drop data.
-The function shall return the action used (copy, move, link or private)
-if drop is successful, nil if not."
+ "Functions to call to handle drag-and-drop of known types.
+If the type of the drop is not present in the alist, or the
+function corresponding to the type is nil, the drop of that
+type will be rejected.
+
+Each function takes three arguments: WINDOW, ACTION, and DATA.
+WINDOW is the window where the drop occurred.
+ACTION is the action for this drop (`copy', `move', `link', `private'
+or `ask'), as determined by a previous call to `x-dnd-test-function'.
+DATA is the drop data.
+The function shall return the action it used (one of the above,
+excluding `ask') if drop is successful, nil if not."
:version "22.1"
:type 'alist
:group 'x)
@@ -122,22 +126,27 @@ like xterm) for text."
:group 'x)
(defcustom x-dnd-direct-save-function #'x-dnd-save-direct
- "Function called when a file is dropped that Emacs must save.
-It is called with two arguments: the first is either nil or t,
-and the second is a string.
-
-If the first argument is t, the second argument is the name the
-dropped file should be saved under. The function should return a
-complete file name describing where the file should be saved.
-
-It can also return nil, which means to cancel the drop.
-
-If the first argument is nil, the second is the name of the file
-that was dropped."
+ "Function called when a file is dropped via XDS protocol.
+The value should be a function of two arguments that supports
+the X Direct Save (XDS) protocol. The function will be called
+twice during the protocol execution.
+
+When the function is called with the first argument non-nil,
+it should return an absolute file name whose base name is
+the value of the second argument, a string. The return value
+is the file name for the dragged file to be saved. The function
+can also return nil if saving the file should be refused for some
+reason; in that case the drop will be canceled.
+
+When the function is called with the first argument nil, the
+second argument specifies the file name where the file was saved;
+the function should then do whatever is appropriate when such a
+file is saved, like show the file in the Dired buffer or visit
+the file."
:version "29.1"
- :type '(choice (const :tag "Prompt for name before saving"
+ :type '(choice (const :tag "Prompt for file name to save"
x-dnd-save-direct)
- (const :tag "Save and open immediately without prompting"
+ (const :tag "Save in `default-directory' without prompting"
x-dnd-save-direct-immediately)
(function :tag "Other function"))
:group 'x)
@@ -222,14 +231,14 @@ any protocol specific data.")
(cdr (x-dnd-get-state-cons-for-frame frame-or-window)))
(defun x-dnd-default-test-function (_window _action types)
- "The default test function for drag and drop.
+ "The default test function for drag-and-drop.
WINDOW is where the mouse is when this function is called. It
may be a frame if the mouse is over the menu bar, scroll bar or
tool bar. ACTION is the suggested action from the source, and
TYPES are the types the drop data can have. This function only
accepts drops with types in `x-dnd-known-types'. It always
returns the action `private', unless `types' contains a value
-inside `x-dnd-copy-types'."
+inside `x-dnd-copy-types', in which case it may return `copy'."
(let ((type (x-dnd-choose-type types)))
(when type (let ((list x-dnd-copy-types))
(catch 'out
@@ -1564,17 +1573,24 @@ was taken, or the direct save failed."
(when (not (equal file-name original-file-name))
(delete-file file-name)))))
-(defun x-dnd-save-direct (need-name name)
- "Handle dropping a file that should be saved immediately.
-NEED-NAME tells whether or not the file was not yet saved. NAME
-is either the name of the file, or the name the drop source wants
-us to save under.
+(defun x-dnd-save-direct (need-name filename)
+ "Handle dropping a file FILENAME that should be saved first, asking the user.
+NEED-NAME non-nil means the caller requests the full absolute
+file name of FILENAME under which to save it; FILENAME is just
+the base name in that case. The function then prompts the user
+for where to save to file and returns the result to the caller.
+
+NEED-NAME nil means the file was saved as FILENAME (which should
+be the full absolute file name in that case). The function then
+refreshes the Dired display, if the current buffer is in Dired
+mode, or visits the file otherwise.
-Prompt the user for a file name, then open it."
+This function is intended to be the value of `x-dnd-direct-save-function',
+which see."
(if need-name
(let ((file-name (read-file-name "Write file: "
default-directory
- nil nil name)))
+ nil nil filename)))
(when (file-exists-p file-name)
(unless (y-or-n-p (format-message
"File `%s' exists; overwrite? " file-name))
@@ -1584,18 +1600,18 @@ Prompt the user for a file name, then open it."
;; interface can be found.
(if (derived-mode-p 'dired-mode)
(revert-buffer)
- (find-file name))))
+ (find-file filename))))
-(defun x-dnd-save-direct-immediately (need-name name)
- "Save and open a dropped file, like `x-dnd-save-direct'.
-NEED-NAME tells whether or not the file was not yet saved. NAME
-is either the name of the file, or the name the drop source wants
-us to save under.
+(defun x-dnd-save-direct-immediately (need-name filename)
+ "Handle dropping a file FILENAME that should be saved first.
+Like `x-dnd-save-direct', but do not prompt for the file name;
+instead, return its absolute file name for saving in the current
+directory.
-Unlike `x-dnd-save-direct', do not prompt for the name by which
-to save the file. Simply save it in the current directory."
+This function is intended to be the value of `x-dnd-direct-save-function',
+which see."
(if need-name
- (let ((file-name (expand-file-name name)))
+ (let ((file-name (expand-file-name filename)))
(when (file-exists-p file-name)
(unless (y-or-n-p (format-message
"File `%s' exists; overwrite? " file-name))
@@ -1605,7 +1621,7 @@ to save the file. Simply save it in the current directory."
;; interface can be found.
(if (derived-mode-p 'dired-mode)
(revert-buffer)
- (find-file name))))
+ (find-file filename))))
(defun x-dnd-handle-octet-stream-for-drop (save-to)
"Save the contents of the XDS selection to SAVE-TO.