all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Writing a function for a indented copy of a region
@ 2008-12-17 13:31 Decebal
  2008-12-17 15:59 ` Drew Adams
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Decebal @ 2008-12-17 13:31 UTC (permalink / raw)
  To: help-gnu-emacs

A lot of times I need to copy a part of a (log) file for an e-mail. I
like to indent this (default with four spaces). At this moment I do
this by hand. But I would like to do this with a function.
What I would like this function to do is take the part that is
selected, indent this with (default) four spaces, put the indented
region in the kill-ring and undo the indent. Has anyone a pointer
about how to code this?


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

* RE: Writing a function for a indented copy of a region
  2008-12-17 13:31 Writing a function for a indented copy of a region Decebal
@ 2008-12-17 15:59 ` Drew Adams
  2008-12-17 16:26 ` Matthias
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Drew Adams @ 2008-12-17 15:59 UTC (permalink / raw)
  To: 'Decebal', help-gnu-emacs

> A lot of times I need to copy a part of a (log) file for an e-mail. I
> like to indent this (default with four spaces). At this moment I do
> this by hand. But I would like to do this with a function.
> What I would like this function to do is take the part that is
> selected, indent this with (default) four spaces, put the indented
> region in the kill-ring and undo the indent. Has anyone a pointer
> about how to code this?

`C-x TAB' is `indent-rigidly'
`M-w' copies the region to the `kill-ring'





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

* Re: Writing a function for a indented copy of a region
  2008-12-17 13:31 Writing a function for a indented copy of a region Decebal
  2008-12-17 15:59 ` Drew Adams
@ 2008-12-17 16:26 ` Matthias
       [not found] ` <mailman.2956.1229529567.26697.help-gnu-emacs@gnu.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Matthias @ 2008-12-17 16:26 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal <CLDWesterhof@gmail.com> writes:

> What I would like this function to do is take the part that is 
> selected, indent this with (default) four spaces, put the 
> indented region in the kill-ring and undo the indent. Has anyone 
> a pointer about how to code this?

Why don't you use a keyboard macro?

First, select the text to indent and kill; Then `C-x (' to start 
defining a keyboard macro, `M-x replace-regexp' the beginning of 
line (that is "^") with four spaces, etc. Then `C-x )' to finish 
the macro definition.

Then to call the macro you just `C-x e'. Read the manual to learn how
to give it a name, save it to file, etc.
-- 
Matthias


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

* Re: Writing a function for a indented copy of a region
       [not found] ` <mailman.2956.1229529567.26697.help-gnu-emacs@gnu.org>
@ 2008-12-17 17:09   ` Decebal
  2008-12-17 18:49     ` Drew Adams
  0 siblings, 1 reply; 15+ messages in thread
From: Decebal @ 2008-12-17 17:09 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 dec, 16:59, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > A lot of times I need to copy a part of a (log) file for an e-mail. I
> > like to indent this (default with four spaces). At this moment I do
> > this by hand. But I would like to do this with a function.
> > What I would like this function to do is take the part that is
> > selected, indent this with (default) four spaces, put the indented
> > region in the kill-ring and undo the indent. Has anyone a pointer
> > about how to code this?
>
> `C-x TAB' is `indent-rigidly'
> `M-w' copies the region to the `kill-ring'

But the first statement unselects the region, that is why I want to
write an elisp function to call after I selected the region. Is it
possible to see if there is a region selected in an elisp function?
What I was thinking about was to put the start and the end of the
region in registers and use those registers in the function to mark
the region again after I indented to put the indented text into the
kill-ring. After that I should do an undo. And then the file is not
changed, but I have the indented region in the kill-ring.


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

* RE: Writing a function for a indented copy of a region
  2008-12-17 17:09   ` Decebal
@ 2008-12-17 18:49     ` Drew Adams
  0 siblings, 0 replies; 15+ messages in thread
From: Drew Adams @ 2008-12-17 18:49 UTC (permalink / raw)
  To: 'Decebal', help-gnu-emacs

> > > A lot of times I need to copy a part of a (log) file for 
> > > an e-mail. I like to indent this (default with four spaces).
> > > At this moment I do this by hand. But I would like to do
> > > this with a function.
> > > What I would like this function to do is take the part that is
> > > selected, indent this with (default) four spaces, put the indented
> > > region in the kill-ring and undo the indent. Has anyone a pointer
> > > about how to code this?
> >
> > `C-x TAB' is `indent-rigidly'
> > `M-w' copies the region to the `kill-ring'
> 
> But the first statement unselects the region,

It _deactivates_ the region (the text is still selected). (I assume you are
using transient-mark-mode, otherwise, there is no notion of active region.)

You can re-activate the region at any time using `C-x C-x' (repeat it if you
care which end point is).

From Lisp code, it often doesn't matter if the region is active -
`kill-ring-save' (`C-w') doesn't care, for instance.

You can test whether it is active by examining the value of (buffer-local)
variable `mark-active'.

I assume that you want to expand the region to include the whole lines at point
and mark. Does this do what you want?

(defun foo (cols beg end)
  (interactive "p\nr")
  (indent-rigidly
   (save-excursion (goto-char beg) (forward-line 0) (point))
   (save-excursion (goto-char end) (forward-line 1) (point))
   cols)
  (copy-region-as-kill
   (save-excursion (goto-char beg) (forward-line 0) (point))
   (save-excursion (goto-char end) (forward-line 1) (point))))

Most of the complication here is just to pick up the whole lines where point and
mark are. And you need to do that twice, because point moves when the region is
indented.

`kill-ring-save' would be OK instead of `copy-region-as-kill', but the latter is
a bit simpler.

Unless I misunderstand what you want, that should do it. And it doesn't matter
whether you use transient-mark-mode or whether the region is active.

If you want the _un_indented region copied, then reverse the order of
`indent-rigidly' and `copy-region-as-kill'. And if you don't care about whole
lines, and just want to copy the original region, then things are simpler:

(defun foo (cols beg end)
  (interactive "p\nr")
  (copy-region-as-kill beg end)
  (indent-rigidly beg end cols))

Anyway, you get the idea. Fiddle, depending on what you really want.

> that is why I want to
> write an elisp function to call after I selected the region. Is it
> possible to see if there is a region selected in an elisp function?
> What I was thinking about was to put the start and the end of the
> region in registers and use those registers in the function to mark
> the region again after I indented to put the indented text into the
> kill-ring. After that I should do an undo. And then the file is not
> changed, but I have the indented region in the kill-ring.

Unless I misunderstand what you want, you don't need to do any of that.

And as Matthias mentioned, it's often a good idea to just create a macro to do
what you want. That too should work in this case. That's why I originally
suggested calling the commands interactively.






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

* Re: Writing a function for a indented copy of a region
  2008-12-17 13:31 Writing a function for a indented copy of a region Decebal
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.2956.1229529567.26697.help-gnu-emacs@gnu.org>
@ 2008-12-17 19:18 ` Decebal
  2008-12-17 19:47   ` Andreas Politz
  2008-12-17 22:58   ` Decebal
  2008-12-18 13:11 ` Decebal
  4 siblings, 2 replies; 15+ messages in thread
From: Decebal @ 2008-12-17 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 dec, 14:31, Decebal <CLDWester...@gmail.com> wrote:
> A lot of times I need to copy a part of a (log) file for an e-mail. I
> like to indent this (default with four spaces). At this moment I do
> this by hand. But I would like to do this with a function.
> What I would like this function to do is take the part that is
> selected, indent this with (default) four spaces, put the indented
> region in the kill-ring and undo the indent. Has anyone a pointer
> about how to code this?

I found a way. In my .emacs I put:
(defun my-indented-yank(indent)
  "Put indented region in the kill-ring"
  (interactive "p")
  (setq indent (cond ((eq indent 0) 1)
                     ((eq indent 1) 4)
                     (t indent)
               )
  )
  (indent-rigidly (region-beginning) (region-end) indent)
  (copy-region-as-kill (region-beginning) (region-end))
  (undo)
)

It looks like this satifies my demands. ;-}
In this way the default indent is 4. If I need an indent of one I can
use 'C-u 0'.

The only thing is that the 'GNU Emacs Lisp Reference Manual' says that
I should not use 'copy-region-as-kill'. I should use 'kill-new' or
'kill-append'. But those do not work with a region. What am I missing?


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 19:18 ` Decebal
@ 2008-12-17 19:47   ` Andreas Politz
  2008-12-17 23:04     ` Decebal
  2008-12-17 23:37     ` Decebal
  2008-12-17 22:58   ` Decebal
  1 sibling, 2 replies; 15+ messages in thread
From: Andreas Politz @ 2008-12-17 19:47 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal wrote:
> On 17 dec, 14:31, Decebal <CLDWester...@gmail.com> wrote:
>> A lot of times I need to copy a part of a (log) file for an e-mail. I
>> like to indent this (default with four spaces). At this moment I do
>> this by hand. But I would like to do this with a function.
>> What I would like this function to do is take the part that is
>> selected, indent this with (default) four spaces, put the indented
>> region in the kill-ring and undo the indent. Has anyone a pointer
>> about how to code this?
> 
> I found a way. In my .emacs I put:
> (defun my-indented-yank(indent)
>   "Put indented region in the kill-ring"
>   (interactive "p")
>   (setq indent (cond ((eq indent 0) 1)
>                      ((eq indent 1) 4)
>                      (t indent)
>                )
>   )
>   (indent-rigidly (region-beginning) (region-end) indent)
>   (copy-region-as-kill (region-beginning) (region-end))
>   (undo)
> )
> 
> It looks like this satifies my demands. ;-}
> In this way the default indent is 4. If I need an indent of one I can
> use 'C-u 0'.
> 
> The only thing is that the 'GNU Emacs Lisp Reference Manual' says that
> I should not use 'copy-region-as-kill'. I should use 'kill-new' or
> 'kill-append'. But those do not work with a region. What am I missing?

Why not work with a string, instead of messing with your buffers undo history.

(defun kill-save-indent-region (indent start end)
   (interactive "p\nr")
   (kill-new (replace-regexp-in-string
	     "^"			;or "^\\s-*"
	     (format (format "%%%ds" (case indent
				       (0 1)
				       (1 4)
				       (t indent)))
		     "")
	     (buffer-substring start end)))
   (deactivate-mark))

-ap


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 19:18 ` Decebal
  2008-12-17 19:47   ` Andreas Politz
@ 2008-12-17 22:58   ` Decebal
  1 sibling, 0 replies; 15+ messages in thread
From: Decebal @ 2008-12-17 22:58 UTC (permalink / raw)
  To: help-gnu-emacs

I found a better way.

(defun my-indented-yank(indent)
  "Put indented region in the kill-ring"
  (interactive "p")
  (if mark-active
      (let (do-kill)
        (setq indent (cond ((eq indent 0) 1)
                           ((eq indent 1) 4)
                           (t indent)
                           )
              )
        (if (< indent 0)
            (setq indent  (- 0 indent)
                  do-kill t
                  )
          )
        (indent-rigidly (region-beginning) (region-end) indent)
        (if do-kill
            (kill-region (region-beginning) (region-end))
          (copy-region-as-kill (region-beginning) (region-end))
          (undo)
          )
        )
    (message "my-indented-yank needs a region")
    )
  )
(global-set-key (kbd "C-c C-w") 'my-indented-yank)

Now a negative value will kill the region instead of yanking it and
when no region is selected an apriote message will be displayed.
I have also bind the funtion to a a key combination. Is my choice a
good one, or is there a better key combination?


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 19:47   ` Andreas Politz
@ 2008-12-17 23:04     ` Decebal
  2008-12-17 23:37     ` Decebal
  1 sibling, 0 replies; 15+ messages in thread
From: Decebal @ 2008-12-17 23:04 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 dec, 20:47, Andreas Politz <poli...@fh-trier.de> wrote:
> Decebal wrote:
> > On 17 dec, 14:31, Decebal <CLDWester...@gmail.com> wrote:
> >> A lot of times I need to copy a part of a (log) file for an e-mail. I
> >> like to indent this (default with four spaces). At this moment I do
> >> this by hand. But I would like to do this with a function.
> >> What I would like this function to do is take the part that is
> >> selected, indent this with (default) four spaces, put the indented
> >> region in the kill-ring and undo the indent. Has anyone a pointer
> >> about how to code this?
>
> > I found a way. In my .emacs I put:
> > (defun my-indented-yank(indent)
> >   "Put indented region in the kill-ring"
> >   (interactive "p")
> >   (setq indent (cond ((eq indent 0) 1)
> >                      ((eq indent 1) 4)
> >                      (t indent)
> >                )
> >   )
> >   (indent-rigidly (region-beginning) (region-end) indent)
> >   (copy-region-as-kill (region-beginning) (region-end))
> >   (undo)
> > )
>
> > It looks like this satifies my demands. ;-}
> > In this way the default indent is 4. If I need an indent of one I can
> > use 'C-u 0'.
>
> > The only thing is that the 'GNU Emacs Lisp Reference Manual' says that
> > I should not use 'copy-region-as-kill'. I should use 'kill-new' or
> > 'kill-append'. But those do not work with a region. What am I missing?
>
> Why not work with a string, instead of messing with your buffers undo history.
>
> (defun kill-save-indent-region (indent start end)
>    (interactive "p\nr")
>    (kill-new (replace-regexp-in-string
>              "^"                      ;or "^\\s-*"
>              (format (format "%%%ds" (case indent
>                                        (0 1)
>                                        (1 4)
>                                        (t indent)))
>                      "")
>              (buffer-substring start end)))
>    (deactivate-mark))
>
> -ap

I have just started with programming in elisp. ;-}
So I still need to learn a lot.  I'll try to understand your code.


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 19:47   ` Andreas Politz
  2008-12-17 23:04     ` Decebal
@ 2008-12-17 23:37     ` Decebal
  2008-12-18  0:27       ` Andreas Politz
  1 sibling, 1 reply; 15+ messages in thread
From: Decebal @ 2008-12-17 23:37 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 dec, 20:47, Andreas Politz <poli...@fh-trier.de> wrote:
> Why not work with a string, instead of messing with your buffers undo history.
>
> (defun kill-save-indent-region (indent start end)
>    (interactive "p\nr")
>    (kill-new (replace-regexp-in-string
>              "^"                      ;or "^\\s-*"
>              (format (format "%%%ds" (case indent
>                                        (0 1)
>                                        (1 4)
>                                        (t indent)))
>                      "")
>              (buffer-substring start end)))
>    (deactivate-mark))

Looking at your code I should replace:
        (indent-rigidly (region-beginning) (region-end) indent)
        (if do-kill
            (kill-region (region-beginning) (region-end))
          (copy-region-as-kill (region-beginning) (region-end))
          (undo)
          )
with:
        (kill-new (replace-regexp-in-string
                   "^"
                   (format (format "%%%ds" indent) "")
                   (filter-buffer-substring (region-beginning) (region-
end) do-kill)
                   )
                  )

but then I get that filter-buffer-substring is void. What am I doing
wrong?


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 23:37     ` Decebal
@ 2008-12-18  0:27       ` Andreas Politz
  2008-12-18  0:49         ` Decebal
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Politz @ 2008-12-18  0:27 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal wrote:
> On 17 dec, 20:47, Andreas Politz <poli...@fh-trier.de> wrote:
>> Why not work with a string, instead of messing with your buffers undo history.
>>
>> (defun kill-save-indent-region (indent start end)
>>    (interactive "p\nr")
>>    (kill-new (replace-regexp-in-string
>>              "^"                      ;or "^\\s-*"
>>              (format (format "%%%ds" (case indent
>>                                        (0 1)
>>                                        (1 4)
>>                                        (t indent)))
>>                      "")
>>              (buffer-substring start end)))
>>    (deactivate-mark))
> 
> Looking at your code I should replace:
>         (indent-rigidly (region-beginning) (region-end) indent)
>         (if do-kill
>             (kill-region (region-beginning) (region-end))
>           (copy-region-as-kill (region-beginning) (region-end))
>           (undo)
>           )
> with:
>         (kill-new (replace-regexp-in-string
>                    "^"
>                    (format (format "%%%ds" indent) "")
>                    (filter-buffer-substring (region-beginning) (region-
> end) do-kill)
>                    )
>                   )
> 
> but then I get that filter-buffer-substring is void. What am I doing
> wrong?

You are using a undefined function ?

-ap


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

* Re: Writing a function for a indented copy of a region
  2008-12-18  0:27       ` Andreas Politz
@ 2008-12-18  0:49         ` Decebal
  0 siblings, 0 replies; 15+ messages in thread
From: Decebal @ 2008-12-18  0:49 UTC (permalink / raw)
  To: help-gnu-emacs

On 18 dec, 01:27, Andreas Politz <poli...@fh-trier.de> wrote:
> > Looking at your code I should replace:
> >         (indent-rigidly (region-beginning) (region-end) indent)
> >         (if do-kill
> >             (kill-region (region-beginning) (region-end))
> >           (copy-region-as-kill (region-beginning) (region-end))
> >           (undo)
> >           )
> > with:
> >         (kill-new (replace-regexp-in-string
> >                    "^"
> >                    (format (format "%%%ds" indent) "")
> >                    (filter-buffer-substring (region-beginning) (region-
> > end) do-kill)
> >                    )
> >                   )
>
> > but then I get that filter-buffer-substring is void. What am I doing
> > wrong?
>
> You are using a undefined function ?

Looks like it yes. But http://www.gnu.org/software/emacs/elisp/html_node/Buffer-Contents.html
says that the functions exists. ???


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

* Re: Writing a function for a indented copy of a region
  2008-12-17 13:31 Writing a function for a indented copy of a region Decebal
                   ` (3 preceding siblings ...)
  2008-12-17 19:18 ` Decebal
@ 2008-12-18 13:11 ` Decebal
  2008-12-18 15:05   ` Andreas Politz
  4 siblings, 1 reply; 15+ messages in thread
From: Decebal @ 2008-12-18 13:11 UTC (permalink / raw)
  To: help-gnu-emacs

On 17 dec, 14:31, Decebal <CLDWester...@gmail.com> wrote:
> A lot of times I need to copy a part of a (log) file for an e-mail. I
> like to indent this (default with four spaces). At this moment I do
> this by hand. But I would like to do this with a function.
> What I would like this function to do is take the part that is
> selected, indent this with (default) four spaces, put the indented
> region in the kill-ring and undo the indent. Has anyone a pointer
> about how to code this?

I have made a better (and more generally) again.

The function indented-yank is a specialised version of my-headed-yank,
so I wrote that one also. ;-}
I also needed a function to remove a region without putting it in the
kill-ring, so I also made the function my-remove-region.
I made key-combinations for al the three functions.
Are there standards for naming functions and asigning functions to key
combinations?

The code:
    (defun my-remove-region(begin end)
      "Delete region without putting it in the kill-ring"
      (interactive "r")
      (kill-region begin end)
      (pop kill-ring)
      )
    (global-set-key (kbd "C-c C-r") 'my-remove-region)

    (defun my-headed-yank(head begin end do-kill)
      "Put region with 'head' prepended to every line in the kill-
ring"
      (interactive "sHead: \nr\nnKill Region? ")
      (kill-new (replace-regexp-in-string
                 "^"
                 head
                 (buffer-substring begin end)
                 )
                )
      (if do-kill
          (my-remove-region begin end)
        )
      (deactivate-mark)
      )
    (global-set-key (kbd "C-c C-h") 'my-headed-yank)

    (defun my-indented-yank(indent begin end)
      "Put indented region in the kill-ring"
      (interactive "p\nr")
      (setq indent (cond ((eq indent 0) 1)
                         ((eq indent 1) 4)
                         (t indent)
                         )
            )
      (let ((do-kill) (head))
        (if (< indent 0)
            (setq indent  (- 0 indent)
                  do-kill t
                  )
          )
        (setq head
              (format (format "%%%ds" indent) "")
              )
        (my-headed-yank head begin end do-kill)
        )
      )
    (global-set-key (kbd "C-c C-w") 'my-indented-yank)


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

* Re: Writing a function for a indented copy of a region
  2008-12-18 13:11 ` Decebal
@ 2008-12-18 15:05   ` Andreas Politz
  2008-12-18 15:48     ` Decebal
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Politz @ 2008-12-18 15:05 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal wrote:
> On 17 dec, 14:31, Decebal <CLDWester...@gmail.com> wrote:
>> A lot of times I need to copy a part of a (log) file for an e-mail. I
>> like to indent this (default with four spaces). At this moment I do
>> this by hand. But I would like to do this with a function.
>> What I would like this function to do is take the part that is
>> selected, indent this with (default) four spaces, put the indented
>> region in the kill-ring and undo the indent. Has anyone a pointer
>> about how to code this?
> 
> I have made a better (and more generally) again.
> 
> The function indented-yank is a specialised version of my-headed-yank,
> so I wrote that one also. ;-}
> I also needed a function to remove a region without putting it in the
> kill-ring, so I also made the function my-remove-region.
> I made key-combinations for al the three functions.
> Are there standards for naming functions and asigning functions to key
> combinations?
> 

It is mentioned somewhere in the info files, that C-c <char> is/should be
reserved for the user. C-c C-<char> is often used by major-modes,
whose keymap will potentially shadow your global-map .

> The code:
>     (defun my-remove-region(begin end)
>       "Delete region without putting it in the kill-ring"
>       (interactive "r")
>       (kill-region begin end)
>       (pop kill-ring)
>       )
Have a look at `delete-region'.

-ap
>     (global-set-key (kbd "C-c C-r") 'my-remove-region)
> 
>     (defun my-headed-yank(head begin end do-kill)
>       "Put region with 'head' prepended to every line in the kill-
> ring"
>       (interactive "sHead: \nr\nnKill Region? ")
>       (kill-new (replace-regexp-in-string
>                  "^"
>                  head
>                  (buffer-substring begin end)
>                  )
>                 )
>       (if do-kill
>           (my-remove-region begin end)
>         )
>       (deactivate-mark)
>       )
>     (global-set-key (kbd "C-c C-h") 'my-headed-yank)
> 
>     (defun my-indented-yank(indent begin end)
>       "Put indented region in the kill-ring"
>       (interactive "p\nr")
>       (setq indent (cond ((eq indent 0) 1)
>                          ((eq indent 1) 4)
>                          (t indent)
>                          )
>             )
>       (let ((do-kill) (head))
>         (if (< indent 0)
>             (setq indent  (- 0 indent)
>                   do-kill t
>                   )
>           )
>         (setq head
>               (format (format "%%%ds" indent) "")
>               )
>         (my-headed-yank head begin end do-kill)
>         )
>       )
>     (global-set-key (kbd "C-c C-w") 'my-indented-yank)


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

* Re: Writing a function for a indented copy of a region
  2008-12-18 15:05   ` Andreas Politz
@ 2008-12-18 15:48     ` Decebal
  0 siblings, 0 replies; 15+ messages in thread
From: Decebal @ 2008-12-18 15:48 UTC (permalink / raw)
  To: help-gnu-emacs

On 18 dec, 16:05, Andreas Politz <poli...@fh-trier.de> wrote:
> Decebal wrote:
> > I made key-combinations for al the three functions.
> > Are there standards for naming functions and asigning functions to key
> > combinations?
>
> It is mentioned somewhere in the info files, that C-c <char> is/should be
> reserved for the user. C-c C-<char> is often used by major-modes,
> whose keymap will potentially shadow your global-map .

I saw that. My keys conflict with shell-mode. Have to dink about
something better.


> > The code:
> >     (defun my-remove-region(begin end)
> >       "Delete region without putting it in the kill-ring"
> >       (interactive "r")
> >       (kill-region begin end)
> >       (pop kill-ring)
> >       )
>
> Have a look at `delete-region'.

Better use that. ;-]


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

end of thread, other threads:[~2008-12-18 15:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-17 13:31 Writing a function for a indented copy of a region Decebal
2008-12-17 15:59 ` Drew Adams
2008-12-17 16:26 ` Matthias
     [not found] ` <mailman.2956.1229529567.26697.help-gnu-emacs@gnu.org>
2008-12-17 17:09   ` Decebal
2008-12-17 18:49     ` Drew Adams
2008-12-17 19:18 ` Decebal
2008-12-17 19:47   ` Andreas Politz
2008-12-17 23:04     ` Decebal
2008-12-17 23:37     ` Decebal
2008-12-18  0:27       ` Andreas Politz
2008-12-18  0:49         ` Decebal
2008-12-17 22:58   ` Decebal
2008-12-18 13:11 ` Decebal
2008-12-18 15:05   ` Andreas Politz
2008-12-18 15:48     ` Decebal

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.