GNU bug report logs -
#24398
[PATCH] Refactor common code in {upcase, downcase, capitalize}-word functions
Previous Next
Reported by: Michal Nazarewicz <mina86 <at> mina86.com>
Date: Fri, 9 Sep 2016 22:00:03 UTC
Severity: wishlist
Tags: patch
Done: Michal Nazarewicz <mina86 <at> mina86.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24398 in the body.
You can then email your comments to 24398 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24398
; Package
emacs
.
(Fri, 09 Sep 2016 22:00:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michal Nazarewicz <mina86 <at> mina86.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 09 Sep 2016 22:00:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* src/casefiddle.c (operate_on_word): Removed in favour of…
(casify_word) …new function which does what operate_on_word did plus
what all of the common code from *-word functions.
(upcase-word, downcase-word, capitalize-word): Move code common between
those functions (pretty much the whole body of those functions) into
casify_word and use that instead of now deleted operato_on_word.
---
src/casefiddle.c | 44 +++++++++++++++++---------------------------
1 file changed, 17 insertions(+), 27 deletions(-)
Unless there are any comments, I’m goning to push this in a few days.
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 6114a6f..6c64d67 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -376,22 +376,27 @@ character positions to operate on. */)
}
static Lisp_Object
-operate_on_word (Lisp_Object arg, ptrdiff_t *newpoint)
+casify_word (enum case_action flag, Lisp_Object arg)
{
- Lisp_Object val;
- ptrdiff_t farend;
+ Lisp_Object beg, end;
+ ptrdiff_t newpoint;
EMACS_INT iarg;
CHECK_NUMBER (arg);
iarg = XINT (arg);
- farend = scan_words (PT, iarg);
- if (!farend)
- farend = iarg > 0 ? ZV : BEGV;
- *newpoint = PT > farend ? PT : farend;
- XSETFASTINT (val, farend);
+ newpoint = scan_words (PT, iarg);
+ if (!newpoint)
+ newpoint = iarg > 0 ? ZV : BEGV;
+
+ XSETFASTINT (beg, PT);
+ XSETFASTINT (end, newpoint);
+ if (PT > newpoint)
+ newpoint = PT;
+
+ casify_region (flag, beg, end);
- return val;
+ SET_PT (newpoint);
}
DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 1, "p",
@@ -404,12 +409,7 @@ With negative argument, convert previous words but do not move.
See also `capitalize-word'. */)
(Lisp_Object arg)
{
- Lisp_Object beg, end;
- ptrdiff_t newpoint;
- XSETFASTINT (beg, PT);
- end = operate_on_word (arg, &newpoint);
- casify_region (CASE_UP, beg, end);
- SET_PT (newpoint);
+ casify_word (CASE_UP, arg);
return Qnil;
}
@@ -422,12 +422,7 @@ is ignored when moving forward.
With negative argument, convert previous words but do not move. */)
(Lisp_Object arg)
{
- Lisp_Object beg, end;
- ptrdiff_t newpoint;
- XSETFASTINT (beg, PT);
- end = operate_on_word (arg, &newpoint);
- casify_region (CASE_DOWN, beg, end);
- SET_PT (newpoint);
+ casify_word (CASE_DOWN, arg);
return Qnil;
}
@@ -443,12 +438,7 @@ is ignored when moving forward.
With negative argument, capitalize previous words but do not move. */)
(Lisp_Object arg)
{
- Lisp_Object beg, end;
- ptrdiff_t newpoint;
- XSETFASTINT (beg, PT);
- end = operate_on_word (arg, &newpoint);
- casify_region (CASE_CAPITALIZE, beg, end);
- SET_PT (newpoint);
+ casify_word (CASE_CAPITALIZE, arg);
return Qnil;
}
--
2.8.0.rc3.226.g39d4020
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24398
; Package
emacs
.
(Sat, 10 Sep 2016 06:47:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 24398 <at> debbugs.gnu.org (full text, mbox):
> From: Michal Nazarewicz <mina86 <at> mina86.com>
> Date: Fri, 9 Sep 2016 23:59:19 +0200
>
> * src/casefiddle.c (operate_on_word): Removed in favour of…
> (casify_word) …new function which does what operate_on_word did plus
> what all of the common code from *-word functions.
> (upcase-word, downcase-word, capitalize-word): Move code common between
> those functions (pretty much the whole body of those functions) into
> casify_word and use that instead of now deleted operato_on_word.
^^^^^^^^^^^^^^^
A typo.
Thanks.
Reply sent
to
Michal Nazarewicz <mina86 <at> mina86.com>
:
You have taken responsibility.
(Mon, 12 Sep 2016 11:27:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Michal Nazarewicz <mina86 <at> mina86.com>
:
bug acknowledged by developer.
(Mon, 12 Sep 2016 11:27:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 24398-done <at> debbugs.gnu.org (full text, mbox):
On Sat, Sep 10 2016, Eli Zaretskii wrote:
>> From: Michal Nazarewicz <mina86 <at> mina86.com>
>> Date: Fri, 9 Sep 2016 23:59:19 +0200
>>
>> * src/casefiddle.c (operate_on_word): Removed in favour of…
>> (casify_word) …new function which does what operate_on_word did plus
>> what all of the common code from *-word functions.
>> (upcase-word, downcase-word, capitalize-word): Move code common between
>> those functions (pretty much the whole body of those functions) into
>> casify_word and use that instead of now deleted operato_on_word.
> ^^^^^^^^^^^^^^^
> A typo.
Fixed and pushed.
> Thanks.
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 11 Oct 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 254 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.