all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Docstring updates around `delete[-forward|-backward]-char'.
@ 2014-02-06 14:57 Michal Nazarewicz
  2014-02-07 15:25 ` Stefan Monnier
  2014-02-07 17:16 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Michal Nazarewicz @ 2014-02-06 14:57 UTC (permalink / raw
  To: emacs-devel; +Cc: Chong Yidong, Stefan Monnier

From: Michal Nazarewicz <mina86@mina86.com>

* src/cmds.c (delete-char): Update docstring pointing out that the
function ignores `delete-active-region' and `overwrite-mode'.
Also remove recommendation to use `delete-forward-char' since the
default binding of C-d is `delete-char' rendering the
recommendation a bit hypocritical.

* lisp/simple.el (delete-backward-char): Point to `delete-char' in
docstring and point to differences between the two.
(delete-forward-char): Mark as interactive-only, point to
`delete-char' in docstring and point to differences between the
two.
---
 lisp/ChangeLog |  8 ++++++++
 lisp/simple.el | 13 +++++++++++--
 src/ChangeLog  |  8 ++++++++
 src/cmds.c     |  4 +++-
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ae9b774..b523c28 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-02-06  Michal Nazarewicz  <mina86@mina86.com>
+
+	* simple.el (delete-backward-char): Point to `delete-char' in
+	docstring and point to differences between the two.
+	(delete-forward-char): Mark as interactive-only, point to
+	`delete-char' in docstring and point to differences between the
+	two.
+
 2014-02-06  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp-sh.el (tramp-sh-handle-start-file-process): Use "&&"
diff --git a/lisp/simple.el b/lisp/simple.el
index 2e924c8..058adbe 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -958,7 +958,11 @@ arg, and KILLFLAG is set if N is explicitly specified.
 
 In Overwrite mode, single character backward deletion may replace
 tabs with spaces so as to back over columns, unless point is at
-the end of the line."
+the end of the line.
+
+It is recommended to use `delete-char' instead of this function
+in Emacs lisp code, but note that `delete-char' ignores
+`delete-active-region' and `overwrite-mode'."
   (interactive "p\nP")
   (unless (integerp n)
     (signal 'wrong-type-argument (list 'integerp n)))
@@ -991,7 +995,11 @@ To disable this, set variable `delete-active-region' to nil.
 
 Optional second arg KILLFLAG non-nil means to kill (save in kill
 ring) instead of delete.  Interactively, N is the prefix arg, and
-KILLFLAG is set if N was explicitly specified."
+KILLFLAG is set if N was explicitly specified.
+
+It is recommended to use `delete-char' instead of this function
+in Emacs lisp code, but note that `delete-char' ignores
+`delete-active-region'."
   (interactive "p\nP")
   (unless (integerp n)
     (signal 'wrong-type-argument (list 'integerp n)))
@@ -1005,6 +1013,7 @@ KILLFLAG is set if N was explicitly specified."
 
 	;; Otherwise, do simple deletion.
 	(t (delete-char n killflag))))
+(put 'delete-forward-char 'interactive-only 'delete-char)
 
 (defun mark-whole-buffer ()
   "Put point at beginning and mark at end of buffer.
diff --git a/src/ChangeLog b/src/ChangeLog
index 140d501..9fb7bbd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2014-02-06  Michal Nazarewicz  <mina86@mina86.com>
+
+	* cmds.c (delete-char): Update docstring pointing out that the
+	function ignores `delete-active-region' and `overwrite-mode'.
+	Also remove recommendation to use `delete-forward-char' since the
+	default binding of C-d is `delete-char' rendering the
+	recommendation a bit hypocritical.
+
 2014-02-06  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* nsterm.m (toggleFullScreen:): Hide menubar on secondary monitor
diff --git a/src/cmds.c b/src/cmds.c
index 8d61c19..98a5978 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -229,7 +229,9 @@ Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
 Interactively, N is the prefix arg, and KILLFLAG is set if
 N was explicitly specified.
 
-The command `delete-forward-char' is preferable for interactive use.  */)
+In contrast to `delete-forward-char' and `delete-backward-char' functions,
+`delete-char' does not respect values of `delete-active-region' and
+`overwrite-mode'.  */)
   (Lisp_Object n, Lisp_Object killflag)
 {
   EMACS_INT pos;
-- 
1.8.5.3




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Docstring updates around `delete[-forward|-backward]-char'.
  2014-02-06 14:57 [PATCH] Docstring updates around `delete[-forward|-backward]-char' Michal Nazarewicz
@ 2014-02-07 15:25 ` Stefan Monnier
  2014-02-07 16:59   ` Michal Nazarewicz
  2014-02-07 17:16 ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2014-02-07 15:25 UTC (permalink / raw
  To: Michal Nazarewicz; +Cc: Chong Yidong, emacs-devel

> Also remove recommendation to use `delete-forward-char' since the
> default binding of C-d is `delete-char' rendering the
> recommendation a bit hypocritical.

Hmm... now I wonder why is the default binding to `delete-char' rather
than to `delete-forward-char'?  Seems like an oversight.


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Docstring updates around `delete[-forward|-backward]-char'.
  2014-02-07 15:25 ` Stefan Monnier
@ 2014-02-07 16:59   ` Michal Nazarewicz
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Nazarewicz @ 2014-02-07 16:59 UTC (permalink / raw
  To: Stefan Monnier; +Cc: Chong Yidong, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

>> Also remove recommendation to use `delete-forward-char' since the
>> default binding of C-d is `delete-char' rendering the
>> recommendation a bit hypocritical.

On Fri, Feb 07 2014, Stefan Monnier wrote:
> Hmm... now I wonder why is the default binding to `delete-char' rather
> than to `delete-forward-char'?  Seems like an oversight.

I thought that as well but this was explicitly changed back to
`delete-char'.  [1] changed binding of C-d to use `delete-forward-char'
but than [2] came along and changed it back to `delete-char' to
“decouple C-d and delete, so that the former does not delete the
region.”

[1] http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/100654
[2] http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/102001

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Docstring updates around `delete[-forward|-backward]-char'.
  2014-02-06 14:57 [PATCH] Docstring updates around `delete[-forward|-backward]-char' Michal Nazarewicz
  2014-02-07 15:25 ` Stefan Monnier
@ 2014-02-07 17:16 ` Stefan Monnier
  2014-02-07 23:40   ` [PATCHv2] " Michal Nazarewicz
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2014-02-07 17:16 UTC (permalink / raw
  To: Michal Nazarewicz; +Cc: Chong Yidong, emacs-devel

> Also remove recommendation to use `delete-forward-char' since the
> default binding of C-d is `delete-char' rendering the
> recommendation a bit hypocritical.

Ah, I remember now why C-d is still bound to `delete-char': it's because
when we introduced the delete-active-region feature we wanted to enable
it by default but we didn't want to alienate existing users, so C-d was
left as "don't delete active region" as part of that tradeoff.

The recommendation is still to prefer `delete-forward-char' (which is
indeed the default binding for the `delete' key).


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] Docstring updates around `delete[-forward|-backward]-char'.
  2014-02-07 17:16 ` Stefan Monnier
@ 2014-02-07 23:40   ` Michal Nazarewicz
  2014-03-04  3:16     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Michal Nazarewicz @ 2014-02-07 23:40 UTC (permalink / raw
  To: Stefan Monnier; +Cc: Chong Yidong, emacs-devel

* cmds.c (delete-char): Update docstring pointing out that the
function ignores `delete-active-region' and `overwrite-mode'.

* binding.el: Add comment describing why C-d binds to `delete-char'.

* simple.el (delete-backward-char): Point to `delete-char' in docstring.
(delete-forward-char): Mark as interactive-only and point to
`delete-char' in docstring.
---
 Slightly updated patch.  Feel free to ignore as I'm less convinced this
 change is actually useful than yesterday. ;)

 lisp/ChangeLog   | 8 ++++++++
 lisp/bindings.el | 3 +++
 lisp/simple.el   | 9 +++++++--
 src/ChangeLog    | 5 +++++
 src/cmds.c       | 4 +++-
 5 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ae9b774..989768d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-02-06  Michal Nazarewicz  <mina86@mina86.com>
+
+	* binding.el: Add comment describing why C-d binds to `delete-char'.
+	* simple.el (delete-backward-char): Point to `delete-char' in
+	docstring.
+	(delete-forward-char): Mark as interactive-only and point to
+	`delete-char' in docstring.
+
 2014-02-06  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp-sh.el (tramp-sh-handle-start-file-process): Use "&&"
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 7106c73..64751da 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -873,6 +873,9 @@ if `inhibit-field-text-motion' is non-nil."
 
 ;; Update tutorial--default-keys if you change these.
 (define-key global-map "\177" 'delete-backward-char)
+;; We explicitly want C-d to use `delete-char' instead of
+;; `delete-forward-char' so that it ignores `delete-active-region'.
+;; See commit message for revision 102001 of the repository.
 (define-key global-map "\C-d" 'delete-char)
 
 (define-key global-map "\C-k" 'kill-line)
diff --git a/lisp/simple.el b/lisp/simple.el
index 2e924c8..bf940d2 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -958,7 +958,9 @@ arg, and KILLFLAG is set if N is explicitly specified.
 
 In Overwrite mode, single character backward deletion may replace
 tabs with spaces so as to back over columns, unless point is at
-the end of the line."
+the end of the line.
+
+`delete-char' is recommended instead of this function in Emacs Lisp code."
   (interactive "p\nP")
   (unless (integerp n)
     (signal 'wrong-type-argument (list 'integerp n)))
@@ -991,7 +993,9 @@ To disable this, set variable `delete-active-region' to nil.
 
 Optional second arg KILLFLAG non-nil means to kill (save in kill
 ring) instead of delete.  Interactively, N is the prefix arg, and
-KILLFLAG is set if N was explicitly specified."
+KILLFLAG is set if N was explicitly specified.
+
+`delete-char' is recommended instead of this function in Emacs Lisp code."
   (interactive "p\nP")
   (unless (integerp n)
     (signal 'wrong-type-argument (list 'integerp n)))
@@ -1005,6 +1009,7 @@ KILLFLAG is set if N was explicitly specified."
 
 	;; Otherwise, do simple deletion.
 	(t (delete-char n killflag))))
+(put 'delete-forward-char 'interactive-only 'delete-char)
 
 (defun mark-whole-buffer ()
   "Put point at beginning and mark at end of buffer.
diff --git a/src/ChangeLog b/src/ChangeLog
index 140d501..9853fc6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-06  Michal Nazarewicz  <mina86@mina86.com>
+
+	* cmds.c (delete-char): Update docstring pointing out that the
+	function ignores `delete-active-region' and `overwrite-mode'.
+
 2014-02-06  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* nsterm.m (toggleFullScreen:): Hide menubar on secondary monitor
diff --git a/src/cmds.c b/src/cmds.c
index 8d61c19..59cc7f8 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -229,7 +229,9 @@ Optional second arg KILLFLAG non-nil means kill instead (save in kill ring).
 Interactively, N is the prefix arg, and KILLFLAG is set if
 N was explicitly specified.
 
-The command `delete-forward-char' is preferable for interactive use.  */)
+The command `delete-forward-char' is preferable for interactive use since
+unlike `delete-forward-char' and `delete-backward-char', `delete-char' does
+not respect values of `delete-active-region' and `overwrite-mode'.  */)
   (Lisp_Object n, Lisp_Object killflag)
 {
   EMACS_INT pos;
-- 
1.8.5.3




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCHv2] Docstring updates around `delete[-forward|-backward]-char'.
  2014-02-07 23:40   ` [PATCHv2] " Michal Nazarewicz
@ 2014-03-04  3:16     ` Stefan Monnier
  2014-03-04  8:40       ` Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2014-03-04  3:16 UTC (permalink / raw
  To: Michal Nazarewicz; +Cc: Chong Yidong, emacs-devel

Thanks, installed with some tweaks.  I removed the "`delete-char' is
recommended instead of this function in Emacs Lisp code." thingies,
because these indications should be auto-generated from the
`interactive-only' property, via help-fns-describe-function-functions.

Patch welcome after the trunk re-opens.


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCHv2] Docstring updates around `delete[-forward|-backward]-char'.
  2014-03-04  3:16     ` Stefan Monnier
@ 2014-03-04  8:40       ` Glenn Morris
  2014-03-04 14:13         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2014-03-04  8:40 UTC (permalink / raw
  To: Stefan Monnier; +Cc: Chong Yidong, Michal Nazarewicz, emacs-devel

Stefan Monnier wrote:

> because these indications should be auto-generated from the
> `interactive-only' property, via help-fns-describe-function-functions.
>
> Patch welcome after the trunk re-opens.

I have one waiting.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCHv2] Docstring updates around `delete[-forward|-backward]-char'.
  2014-03-04  8:40       ` Glenn Morris
@ 2014-03-04 14:13         ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2014-03-04 14:13 UTC (permalink / raw
  To: Glenn Morris; +Cc: Chong Yidong, Michal Nazarewicz, emacs-devel

>> because these indications should be auto-generated from the
>> `interactive-only' property, via help-fns-describe-function-functions.
>> Patch welcome after the trunk re-opens.
> I have one waiting.

Cool, thanks,


        Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-04 14:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-06 14:57 [PATCH] Docstring updates around `delete[-forward|-backward]-char' Michal Nazarewicz
2014-02-07 15:25 ` Stefan Monnier
2014-02-07 16:59   ` Michal Nazarewicz
2014-02-07 17:16 ` Stefan Monnier
2014-02-07 23:40   ` [PATCHv2] " Michal Nazarewicz
2014-03-04  3:16     ` Stefan Monnier
2014-03-04  8:40       ` Glenn Morris
2014-03-04 14:13         ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.