Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bug#1120: issues on (put 'insert-date 'delete-selection t)

2 views
Skip to first unread message

xah lee

unread,
Oct 8, 2008, 12:55:27 PM10/8/08
to bug-gn...@gnu.org
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/


Richard M. Stallman

unread,
Oct 8, 2008, 10:59:58 PM10/8/08
to xah lee, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org
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.

Richard M. Stallman

unread,
Oct 8, 2008, 10:59:58 PM10/8/08
to xah lee, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org

xah lee

unread,
Oct 9, 2008, 3:45:10 AM10/9/08
to r...@gnu.org, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org
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/


xah lee

unread,
Oct 9, 2008, 3:45:10 AM10/9/08
to r...@gnu.org, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org

Richard M. Stallman

unread,
Oct 9, 2008, 3:00:21 PM10/9/08
to xah lee, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org
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.


Richard M. Stallman

unread,
Oct 9, 2008, 3:00:21 PM10/9/08
to xah lee, 11...@emacsbugs.donarmstrong.com, bug-gn...@gnu.org
0 new messages