From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: Problems with the capitalization in Word Abbreviation Mode Date: Mon, 6 Oct 2008 21:06:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223354476 6531 80.91.229.12 (7 Oct 2008 04:41:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Oct 2008 04:41:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 07 06:42:12 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kn4Oh-0005Ah-46 for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 06:42:11 +0200 Original-Received: from localhost ([127.0.0.1]:50856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kn4Nd-00048s-4g for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Oct 2008 00:41:05 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!z11g2000prl.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 92 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1223352374 30404 127.0.0.1 (7 Oct 2008 04:06:14 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 7 Oct 2008 04:06:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z11g2000prl.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163122 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:58465 Archived-At: another way to fix letter-case typo problem is to use one of emacs commands to change letter case. There are capitalize-word, downcase-word, upcase-word. Type C-h =E2=80=B9function-name=E2=80=BA to see their default keybindings. There are also several varieties: (upcase obj) (upcase-word 3) (upcase-region beg end) (upcase-initials obj) (upcase-initials-region beg end) (capitalize obj) (capitalize-word n) (capitalize-region myStartPos myEndPos) (downcase) (downcase-word arg) (downcase-region beg end) One problem with them is that you need to move your cursor to the beginning of the word first. For example, if your cursor is on the =E2=80= =9CA=E2=80=9D In =E2=80=9CTHat=E2=80=9D, And You Call downcase-word, but it doesn't do an= ything because it only start at the cursor point to end of word. It would be nice if it'll just automatically perform the operation on the whole word as a region. Another problem is that it only performs one specific operation as opposed to considering the final result. For example, if you have =E2=80=9ConcE upon a time ...=E2=80=9D, and you select the whole sentence a= nd call upcase-initials-region, it becomes =E2=80=9COncE Upon A Time ...=E2=80=9D, = but the capital E is not automatically lowered. Also, most of these commands have a =E2=80=9C-word=E2=80=9D and =E2=80=9C-r= egion=E2=80=9D version... great for precision in elisp programing but not smart as user commands. It would be nice if a region is active, then automatically do the command on the region, else the current word. (emacs is this way because technically, a =E2=80=9Cregion=E2=80=9D always exists. The mode= rn concept of text selection (with highlighting) didn't come to emacs until it had transient-mark-mode, along with the complexity of =E2=80=9Cmark-active= =E2=80=9D. Things would be much simpler if emacs adopted transient-mark-mode by default.) I've combined these into one function and i think fixed the above usability issues: (defun toggle-letter-case () "Toggle the current word or region's letter case. Toggles from 3 cases: upper case, lower case, title case, in that order. Title case means upcase first letter of each word." (interactive) (save-excursion (let (pt pos1 pos2 cap1p cap2p (deactivate-mark nil) (case-fold-search nil)) (setq pt (point)) (if (and transient-mark-mode mark-active) (setq pos1 (region-beginning) pos2 (region-end)) (setq pos1 (car (bounds-of-thing-at-point 'word)) pos2 (cdr (bounds-of-thing-at-point 'word)))) (goto-char pos1) (setq cap1p (looking-at "[A-Z]")) (goto-char (1+ pos1)) (setq cap2p (looking-at "[A-Z]")) (cond ((and (not cap1p) (not cap2p)) (upcase-initials-region pos1 pos2)) ((and cap1p (not cap2p)) (upcase-region pos1 pos2) ) ((and cap1p cap2p) (downcase-region pos1 pos2) ) (t (downcase-region pos1 pos2) ) ) ) ) ) and recently assigned it a single shortcut. See http://xahlee.org/emacs/ergonomic_emacs_keybinding.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84