all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Quick deleting from a comma separated list
@ 2003-12-18 11:04 Urban Gabor
  0 siblings, 0 replies; 5+ messages in thread
From: Urban Gabor @ 2003-12-18 11:04 UTC (permalink / raw)


Hi

I have a question, is there an elegant and quick way to
delete an item from a comma separated list.

Example:

arg1,arg2,arg3
......>

The cursor point is at the 'a' of the second argument. I
want to delete the arg2 and the separating comma. What is
solution if there are spaces after or before the comma?

Thanks in advance. Could you CC the solution privately?

Gabaux
Linux is like a wigwam: no gates, no windows, and an apache
inside!

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

* Re: Quick deleting from a comma separated list
       [not found] <mailman.245.1071749454.868.help-gnu-emacs@gnu.org>
@ 2003-12-18 12:01 ` Pascal Bourguignon
  2003-12-18 12:08 ` Joakim Hove
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pascal Bourguignon @ 2003-12-18 12:01 UTC (permalink / raw)


Urban Gabor <gabaux@freemail.hu> writes:

> Hi
> 
> I have a question, is there an elegant and quick way to
> delete an item from a comma separated list.
> 
> Example:
> 
> arg1,arg2,arg3
> ......>
> 
> The cursor point is at the 'a' of the second argument. I
> want to delete the arg2 and the separating comma. What is
> solution if there are spaces after or before the comma?

M-d C-d C-DEL


If you were there:

 arg1,arg2,arg3
 .....>

You would skip the C-DEL.


-- 
__Pascal_Bourguignon__                              .  *   * . * .* .
http://www.informatimago.com/                        .   *   .   .*
There is no worse tyranny than to force             * .  . /\  (   . *
a man to pay for what he does not                    . .  / .\   . * .
want merely because you think it                    .*.  / *  \  . .
would be good for him. -- Robert Heinlein             . /*   o \     .
http://www.theadvocates.org/                        *   '''||'''   .
SCO Spam-magnet: postmaster@sco.com                 ******************

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

* Re: Quick deleting from a comma separated list
       [not found] <mailman.245.1071749454.868.help-gnu-emacs@gnu.org>
  2003-12-18 12:01 ` Pascal Bourguignon
@ 2003-12-18 12:08 ` Joakim Hove
  2003-12-18 17:14 ` Johan Bockgård
  2003-12-18 18:06 ` Kai Grossjohann
  3 siblings, 0 replies; 5+ messages in thread
From: Joakim Hove @ 2003-12-18 12:08 UTC (permalink / raw)
  Cc: Urban Gabor


Urban Gabor <gabaux@freemail.hu> writes:


> The cursor point is at the 'a' of the second argument. I
> want to delete the arg2 and the separating comma. What is
> solution if there are spaces after or before the comma?

Try this - *not* extensively tested!! Observe that it starts deleting
from point - ignoring where you stand, see comment in code?

(defun csv-kill ()
  (interactive)
  ;;
  ;; Should maybe start here with searching backwards for the beginning "," ??
  ;;
  (let ((p0 (point)))
    (if (search-forward "," (save-excursion (end-of-line) (point)) 't)
	(progn
	  (while (looking-at "[ \t]")
	    (forward-char 1))
	  (kill-region p0 (point)))
      (message "No further comma"))))


HTH - Joakim

-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/

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

* Re: Quick deleting from a comma separated list
       [not found] <mailman.245.1071749454.868.help-gnu-emacs@gnu.org>
  2003-12-18 12:01 ` Pascal Bourguignon
  2003-12-18 12:08 ` Joakim Hove
@ 2003-12-18 17:14 ` Johan Bockgård
  2003-12-18 18:06 ` Kai Grossjohann
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Bockgård @ 2003-12-18 17:14 UTC (permalink / raw)


Urban Gabor <gabaux@freemail.hu> writes:

> I have a question, is there an elegant and quick way to delete an
> item from a comma separated list.
>
> Example:
>
> arg1,arg2,arg3
> ......>

> The cursor point is at the 'a' of the second argument. I want to
> delete the arg2 and the separating comma. What is solution if there
> are spaces after or before the comma?

Move to the beginning of *arg3* and use M-<DEL> (backward-kill-word)
or C-M-<DEL> (backward-kill-sexp).

-- 
Johan Bockgård

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

* Re: Quick deleting from a comma separated list
       [not found] <mailman.245.1071749454.868.help-gnu-emacs@gnu.org>
                   ` (2 preceding siblings ...)
  2003-12-18 17:14 ` Johan Bockgård
@ 2003-12-18 18:06 ` Kai Grossjohann
  3 siblings, 0 replies; 5+ messages in thread
From: Kai Grossjohann @ 2003-12-18 18:06 UTC (permalink / raw)


Urban Gabor <gabaux@freemail.hu> writes:

> I have a question, is there an elegant and quick way to
> delete an item from a comma separated list.

It depends on what exactly is a comma separated list.  In the simplest
case, zap-to-char might do the trick well.  It is by default bound to
M-z, such that "M-z ," will delete from point to the next comma.

But of course, the "real" CSV format specifies that you can use quotes
to "hide" commas in values, such that

    foo, "foo, bar", baz

contains only three values, the first being "foo", the second being
"foo, bar", and the third being "baz".  I think the understanding is
that the quotes around a quoted value are removed.  There are some
weird conventions on quoting quotes.

If this is what you're seeing, then you might need a customized
method.  Please describe the problematic cases where zap-to-char might
fail in more detail.

Kai

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

end of thread, other threads:[~2003-12-18 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-18 11:04 Quick deleting from a comma separated list Urban Gabor
     [not found] <mailman.245.1071749454.868.help-gnu-emacs@gnu.org>
2003-12-18 12:01 ` Pascal Bourguignon
2003-12-18 12:08 ` Joakim Hove
2003-12-18 17:14 ` Johan Bockgård
2003-12-18 18:06 ` Kai Grossjohann

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.