* bug#1120: issues on (put 'insert-date 'delete-selection t)
@ 2008-10-08 16:55 xah lee
2008-10-09 2:59 ` Richard M. Stallman
0 siblings, 1 reply; 4+ messages in thread
From: xah lee @ 2008-10-08 16:55 UTC (permalink / raw)
To: bug-gnu-emacs
according to delete-selection-mode's header file, elisp code that
insert text that wants to respect delete-selection-mode should set
the symbol's delete-selection property to true.
However, this works only when the command is called by a keyboard,
not by M-x.
This appears to be a bug?
Example for reproduction:
(defun insert-date () "Insert current date." (interactive)
(insert (format-time-string "%Y-%m-%d"))
)
(put 'insert-date 'delete-selection t)
then call M-x insert-date, and it'll not replace text selection.
(PS thanks to Drew Adams and Chetan on gnu.emacs.help)
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#1120: issues on (put 'insert-date 'delete-selection t)
2008-10-08 16:55 bug#1120: issues on (put 'insert-date 'delete-selection t) xah lee
@ 2008-10-09 2:59 ` Richard M. Stallman
2008-10-09 7:45 ` xah lee
0 siblings, 1 reply; 4+ messages in thread
From: Richard M. Stallman @ 2008-10-09 2:59 UTC (permalink / raw)
To: xah lee, 1120; +Cc: bug-gnu-emacs
according to delete-selection-mode's header file, elisp code that
insert text that wants to respect delete-selection-mode should set
the symbol's delete-selection property to true.
However, this works only when the command is called by a keyboard,
not by M-x.
This appears to be a bug?
It's intentional. This feature implements expectations that users
have for single-character editing operations in other editors,
where those commands don't have names and there's nothing like M-x.
So there's no reason why M-x should delete the region.
It is better for M-x just to call the function.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#1120: issues on (put 'insert-date 'delete-selection t)
2008-10-09 2:59 ` Richard M. Stallman
@ 2008-10-09 7:45 ` xah lee
2008-10-09 19:00 ` Richard M. Stallman
0 siblings, 1 reply; 4+ messages in thread
From: xah lee @ 2008-10-09 7:45 UTC (permalink / raw)
To: rms; +Cc: 1120, bug-gnu-emacs
Interesting point.
For elisp programers who wish to write extentions where the command's
behaviors change depending on whether user has delete-selection-mode
on, what should they do? Check for mark-active and delete-selection-
mode before any call to the insert function?
also, the current behavior seems to introduce a complexity, where
command behaves differently depending on whether it is invoked by a
keybinding or by M-x.
Xah
∑ http://xahlee.org/
☄
On Oct 8, 2008, at 7:59 PM, Richard M. Stallman wrote:
according to delete-selection-mode's header file, elisp code that
insert text that wants to respect delete-selection-mode should set
the symbol's delete-selection property to true.
However, this works only when the command is called by a keyboard,
not by M-x.
This appears to be a bug?
It's intentional. This feature implements expectations that users
have for single-character editing operations in other editors,
where those commands don't have names and there's nothing like M-x.
So there's no reason why M-x should delete the region.
It is better for M-x just to call the function.
☄
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#1120: issues on (put 'insert-date 'delete-selection t)
2008-10-09 7:45 ` xah lee
@ 2008-10-09 19:00 ` Richard M. Stallman
0 siblings, 0 replies; 4+ messages in thread
From: Richard M. Stallman @ 2008-10-09 19:00 UTC (permalink / raw)
To: xah lee, 1120; +Cc: bug-gnu-emacs
For elisp programers who wish to write extentions where the command's
behaviors change depending on whether user has delete-selection-mode
on, what should they do? Check for mark-active and delete-selection-
mode before any call to the insert function?
If you really want to make behavior depend on those variables,
you need to check them. Whether you check them before or after
calling `insert' is up to you.
But that seems like a strange thing to do.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-09 19:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 16:55 bug#1120: issues on (put 'insert-date 'delete-selection t) xah lee
2008-10-09 2:59 ` Richard M. Stallman
2008-10-09 7:45 ` xah lee
2008-10-09 19:00 ` Richard M. Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).