all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get the ~ functionality of vi
Date: Fri, 27 May 2016 21:37:31 +0200	[thread overview]
Message-ID: <86inxze1hg.fsf@student.uu.se> (raw)
In-Reply-To: 87eg8n51ae.fsf@Equus.decebal.nl

Cecil Westerhof <Cecil@decebal.nl> writes:

> The thing-at-point did not work for me.

OK, try

    (require 'thingatpt)

first.

It is a useful thing even tho your code is
perhaps (?) better in this case.

> I like to flip a lot of characters in one
> swell swoop.

OK, you can use the C-u prefix to do that.

So `C-c f'         is 4^0 = 1,
   `C-u C-c f'     is 4^1 = 4,
   `C-u C-u C-c f' is 4^2 = 16, and so on; and
   `C-u x C-c f'   is x!

This can be implemented like this:

    (require 'cl-macs)

    (defun flip-case (times)
      (interactive "p")
      (cl-dotimes (_ times)
        (let ((c (string-to-char (thing-at-point 'char t))))
          (delete-char 1)
          (cond ((and (>= c ?A) (<= c ?Z)) (insert-char (downcase c)))
                ((and (>= c ?a) (<= c ?z)) (insert-char (upcase c)))
                (t                         (insert-char c)))) ))

    (global-set-key "\C-cf" #'flip-case)

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 42 Blogomatic articles -                   


  parent reply	other threads:[~2016-05-27 19:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 22:36 How to get the ~ functionality of vi Cecil Westerhof
2016-05-27  1:15 ` Emanuel Berg
2016-05-27  4:28   ` Jean-Jacques Rétorré
2016-05-27  8:54     ` Cecil Westerhof
2016-05-27 11:33       ` Thorsten Bonow
2016-05-27 19:41         ` Emanuel Berg
2016-06-02 16:14         ` Kaushal Modi
     [not found]         ` <mailman.703.1464884068.1216.help-gnu-emacs@gnu.org>
2016-06-02 17:15           ` Emanuel Berg
2016-06-02 17:28             ` Kaushal Modi
     [not found]             ` <mailman.715.1464888555.1216.help-gnu-emacs@gnu.org>
2016-06-02 20:39               ` Emanuel Berg
2016-06-02 21:00                 ` Kaushal Modi
2016-06-03  5:07                   ` Marcin Borkowski
     [not found]                 ` <mailman.730.1464901264.1216.help-gnu-emacs@gnu.org>
2016-06-02 21:07                   ` Emanuel Berg
2016-06-03  9:21                     ` Joost Kremers
2016-06-03 10:51                       ` Emanuel Berg
2016-05-27 19:37       ` Emanuel Berg [this message]
2016-05-27 19:37       ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86inxze1hg.fsf@student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.