all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keybinding Default Command and Execution with Argument
@ 2020-11-05 15:41 Christopher Dimech
  2020-11-05 15:58 ` tomas
  0 siblings, 1 reply; 6+ messages in thread
From: Christopher Dimech @ 2020-11-05 15:41 UTC (permalink / raw)
  To: Help Gnu Emacs

I made a simple defun to move the current character over n other characters.
It behaves a differently than transpose-chars, because the cursor point stays
on the same character, rather than moving to the cursor next to the swapped
character to the right.

When using transpose-chars. one can use transpose-chars without any argument,
taking the default of one.

  M-x transpose-chars

Alternatively, one can pass an argument (e.g. 3) as follows

  C-u 3 M-x transpose-chars

Currently, I can only use Skip-Over-Chars with argument.  Is there a way to
use the function Skip-Over-Chars without requiring an argument, but defaulting
the argument to one as what can be done with transpose-chars?


(defun Skip-Over-Chars (n)
   "Skip-Over-Chars transfers character over 'n' other
characters, forward and backward."
   (interactive "N Number of skips: ")
   (forward-char)
   (transpose-chars n)
   (backward-char)
)




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

* Re: Keybinding Default Command and Execution with Argument
  2020-11-05 15:41 Keybinding Default Command and Execution with Argument Christopher Dimech
@ 2020-11-05 15:58 ` tomas
  2020-11-05 16:17   ` Drew Adams
  2020-11-05 16:19   ` Christopher Dimech
  0 siblings, 2 replies; 6+ messages in thread
From: tomas @ 2020-11-05 15:58 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Thu, Nov 05, 2020 at 04:41:11PM +0100, Christopher Dimech wrote:
> I made a simple defun to move the current character over n other characters.
> It behaves a differently than transpose-chars, because the cursor point stays
> on the same character, rather than moving to the cursor next to the swapped
> character to the right.
> 
> When using transpose-chars. one can use transpose-chars without any argument,
> taking the default of one.
> 
>   M-x transpose-chars
> 
> Alternatively, one can pass an argument (e.g. 3) as follows
> 
>   C-u 3 M-x transpose-chars
> 
> Currently, I can only use Skip-Over-Chars with argument.  Is there a way to
> use the function Skip-Over-Chars without requiring an argument, but defaulting
> the argument to one as what can be done with transpose-chars?

Ask `transpose-chars' itself :)

I.e. do

  C-h f transpose-chars

You'll get a small help buffer explaining transpose-chars. Basically the
function's docstring, and then something.

Part of this something is the function's location, like so:

    "transpose-chars is an interactive compiled Lisp function in
     in ‘simple.el’.

     It is bound to C-t.

     [more stuff]"

The simple.el is highlighted as a link. It is a link. If your
Emacs installation is sane, you can put point at this link
(alternatively you click on it), and you get to transpose-char's
definition, in simple.el. There you see:

  (defun transpose-chars (arg)
    "Interchange characters around point, moving forward one character.
  With prefix arg ARG, effect is to take character before point
  and drag it forward past ARG other characters (backward if ARG negative).
  If no argument and at end of line, the previous two chars are exchanged."
    (interactive "*P")
    (when (and (null arg) (eolp) (not (bobp))
          ... ) ...) ...)

So they are using (interactive "P") for that. You can look up what that
means in `interactive's documentation. The asterisk is there to ensure
that the buffer is writable.

Emacs teaches you the tricks of the Grandmasters ;-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* RE: Keybinding Default Command and Execution with Argument
  2020-11-05 15:58 ` tomas
@ 2020-11-05 16:17   ` Drew Adams
  2020-11-05 16:19   ` Christopher Dimech
  1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2020-11-05 16:17 UTC (permalink / raw)
  To: tomas, help-gnu-emacs

> Ask `transpose-chars' itself :)
...
> Emacs teaches you the tricks of the Grandmasters ;-)

Yup.  That's the message: Ask Emacs.



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

* Re: Keybinding Default Command and Execution with Argument
  2020-11-05 15:58 ` tomas
  2020-11-05 16:17   ` Drew Adams
@ 2020-11-05 16:19   ` Christopher Dimech
  2020-11-05 16:24     ` tomas
  1 sibling, 1 reply; 6+ messages in thread
From: Christopher Dimech @ 2020-11-05 16:19 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs


My Emacs is insane then as it does not give me the link to simple.el


> Sent: Thursday, November 05, 2020 at 4:58 PM
> From: tomas@tuxteam.de
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding Default Command and Execution with Argument
>
> On Thu, Nov 05, 2020 at 04:41:11PM +0100, Christopher Dimech wrote:
> > I made a simple defun to move the current character over n other characters.
> > It behaves a differently than transpose-chars, because the cursor point stays
> > on the same character, rather than moving to the cursor next to the swapped
> > character to the right.
> > 
> > When using transpose-chars. one can use transpose-chars without any argument,
> > taking the default of one.
> > 
> >   M-x transpose-chars
> > 
> > Alternatively, one can pass an argument (e.g. 3) as follows
> > 
> >   C-u 3 M-x transpose-chars
> > 
> > Currently, I can only use Skip-Over-Chars with argument.  Is there a way to
> > use the function Skip-Over-Chars without requiring an argument, but defaulting
> > the argument to one as what can be done with transpose-chars?
> 
> Ask `transpose-chars' itself :)
> 
> I.e. do
> 
>   C-h f transpose-chars
> 
> You'll get a small help buffer explaining transpose-chars. Basically the
> function's docstring, and then something.
> 
> Part of this something is the function's location, like so:
> 
>     "transpose-chars is an interactive compiled Lisp function in
>      in ‘simple.el’.
> 
>      It is bound to C-t.
> 
>      [more stuff]"
> 
> The simple.el is highlighted as a link. It is a link. If your
> Emacs installation is sane, you can put point at this link
> (alternatively you click on it), and you get to transpose-char's
> definition, in simple.el. There you see:
> 
>   (defun transpose-chars (arg)
>     "Interchange characters around point, moving forward one character.
>   With prefix arg ARG, effect is to take character before point
>   and drag it forward past ARG other characters (backward if ARG negative).
>   If no argument and at end of line, the previous two chars are exchanged."
>     (interactive "*P")
>     (when (and (null arg) (eolp) (not (bobp))
>           ... ) ...) ...)
> 
> So they are using (interactive "P") for that. You can look up what that
> means in `interactive's documentation. The asterisk is there to ensure
> that the buffer is writable.
> 
> Emacs teaches you the tricks of the Grandmasters ;-)
> 
> Cheers
>  - t
>



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

* Re: Keybinding Default Command and Execution with Argument
  2020-11-05 16:19   ` Christopher Dimech
@ 2020-11-05 16:24     ` tomas
  2020-11-05 16:29       ` Christopher Dimech
  0 siblings, 1 reply; 6+ messages in thread
From: tomas @ 2020-11-05 16:24 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs

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

On Thu, Nov 05, 2020 at 05:19:16PM +0100, Christopher Dimech wrote:
> 
> My Emacs is insane then as it does not give me the link to simple.el

That's absolutely unfortunate. Depending on your platform, you
just have to install some "source" packages?

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: Keybinding Default Command and Execution with Argument
  2020-11-05 16:24     ` tomas
@ 2020-11-05 16:29       ` Christopher Dimech
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher Dimech @ 2020-11-05 16:29 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs





> Sent: Thursday, November 05, 2020 at 5:24 PM
> From: tomas@tuxteam.de
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding Default Command and Execution with Argument
>
> On Thu, Nov 05, 2020 at 05:19:16PM +0100, Christopher Dimech wrote:
> >
> > My Emacs is insane then as it does not give me the link to simple.el
>
> That's absolutely unfortunate. Depending on your platform, you
> just have to install some "source" packages?

I'll got to check out what's missing.

>
> Cheers
>  - t
>



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

end of thread, other threads:[~2020-11-05 16:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-05 15:41 Keybinding Default Command and Execution with Argument Christopher Dimech
2020-11-05 15:58 ` tomas
2020-11-05 16:17   ` Drew Adams
2020-11-05 16:19   ` Christopher Dimech
2020-11-05 16:24     ` tomas
2020-11-05 16:29       ` Christopher Dimech

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.