all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Where is clipper.el's homepage today?
       [not found] <mailman.7939.1160429872.9609.help-gnu-emacs@gnu.org>
@ 2006-10-10 12:51 ` greg.bognar
  2006-10-17  7:37 ` Mathias Dahl
  1 sibling, 0 replies; 8+ messages in thread
From: greg.bognar @ 2006-10-10 12:51 UTC (permalink / raw)


Lennart Borgman wrote:
> I was looking at some convenient way to paste some strings I often use
> personally. On EmacsWiki clipper.el was mentioned, but the link to it
> was broken. Where is it on the Internet today?

If you use a Debian-based distro, clipper is included in the
emacs-goodies package.

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

* Re: Where is clipper.el's homepage today?
       [not found] <mailman.7939.1160429872.9609.help-gnu-emacs@gnu.org>
  2006-10-10 12:51 ` Where is clipper.el's homepage today? greg.bognar
@ 2006-10-17  7:37 ` Mathias Dahl
  2006-11-01 19:31   ` Regular expression search vb
  1 sibling, 1 reply; 8+ messages in thread
From: Mathias Dahl @ 2006-10-17  7:37 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> I was looking at some convenient way to paste some strings I often
> use personally. On EmacsWiki clipper.el was mentioned, but the link
> to it was broken. Where is it on the Internet today?
>
> Is there maybe a better way to do this? (I have no use for template
> in my simple cases I believe.)

Have you tested using some global abbrevs? It's not "pasting" but it
types the text for you.

Abbrevs are really powerful!

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

* Regular expression search
  2006-10-17  7:37 ` Mathias Dahl
@ 2006-11-01 19:31   ` vb
  2006-11-01 20:04     ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: vb @ 2006-11-01 19:31 UTC (permalink / raw)


let's say I need a function to find first printable character on the line 
where the pointer is. This is what I'm trying to use:

(defun vb-first-printable ()
  (interactive)
  (let (limit-position)
    (beginning-of-line)
    (next-line 1)
    (setq limit-position (point))
    (previous-line 1)
    (re-search-forward "\\S" limit-position 't)))

when I try executing this, I get the following error:

====================================================
Debugger entered--Lisp error: (invalid-regexp "Premature end of regular 
expression")
  re-search-forward("\\S" 3543 t)
  (let (limit-position) (beginning-of-line) (next-line 1) (setq limit-position 
(point)) (previous-line 1) (re-search-forward "\\S" limit-position (quote 
t)))
  vb-first-printable()
  call-interactively(vb-first-printable)
===================================================

the same problem happens when I try re-search-forward from the command line: 
if I enter "\S" as the pattern to search, I get "premature end of regular 
expression" error,  but if I enter "\\S" as the regular expression pattern, 
the only thing it finds is this pattern (\\S) itself (as I try it on the same 
file where the source code is).

What am I missing here?

TIA,
\vb

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

* Re: Regular expression search
  2006-11-01 19:31   ` Regular expression search vb
@ 2006-11-01 20:04     ` Kevin Rodgers
  2006-11-01 21:10       ` vb
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2006-11-01 20:04 UTC (permalink / raw)


vb wrote:
> let's say I need a function to find first printable character on the line 
> where the pointer is. This is what I'm trying to use:
> 
> (defun vb-first-printable ()
>   (interactive)
>   (let (limit-position)
>     (beginning-of-line)
>     (next-line 1)
>     (setq limit-position (point))
>     (previous-line 1)
>     (re-search-forward "\\S" limit-position 't)))
> 
> when I try executing this, I get the following error:
> 
> ====================================================
> Debugger entered--Lisp error: (invalid-regexp "Premature end of regular 
> expression")
>   re-search-forward("\\S" 3543 t)
>   (let (limit-position) (beginning-of-line) (next-line 1) (setq limit-position 
> (point)) (previous-line 1) (re-search-forward "\\S" limit-position (quote 
> t)))
>   vb-first-printable()
>   call-interactively(vb-first-printable)
> ===================================================
> 
> the same problem happens when I try re-search-forward from the command line: 
> if I enter "\S" as the pattern to search, I get "premature end of regular 
> expression" error,  but if I enter "\\S" as the regular expression pattern, 
> the only thing it finds is this pattern (\\S) itself (as I try it on the same 
> file where the source code is).
> 
> What am I missing here?

Commands that prompt you for a regexp allow you to enter it directly;
but when calling a Lisp function you have to specify the regexp as a
string, and in order to represent a backslash within a (double quote- 
delimited) string literal you must double it: "This string has 1 
backslash (here: \\) and 1 double quote (here: \")."  And of course
the `\\' regexp matches the backslash character itself.

The manual states:

,----
| `\sC'
|      matches any character whose syntax is C.  Here C is a character
|      that designates a particular syntax class: thus, `w' for word
|      constituent, `-' or ` ' for whitespace, `.' for ordinary
|      punctuation, etc.  *Note Syntax::.
|
| `\SC'
|      matches any character whose syntax is not C.
`----

So you must specify a syntax class `C', e.g. `w' for word constituent,
`-' or ` ' for whitespace, `.' for ordinary punctuation, etc.

But as there is no syntax class for printable or non-printable
characters, that seems like a dead end.  But there is the [:print:]
character class that you can use in regular expressions.

And finally, all that limit-position/next-line/point/previous-line stuff
can be replaced by line-end-position:

(defun vb-first-printable ()
   (interactive)
   (beginning-of-line)
   (re-search-forward "[[:print:]]" (line-end-position)))

-- 
Kevin

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

* Re: Regular expression search
  2006-11-01 20:04     ` Kevin Rodgers
@ 2006-11-01 21:10       ` vb
  2006-11-01 22:23         ` Edward O'Connor
  2006-11-02 18:49         ` Kevin Rodgers
  0 siblings, 2 replies; 8+ messages in thread
From: vb @ 2006-11-01 21:10 UTC (permalink / raw)
  Cc: Kevin Rodgers

Kevin,

thank you for your explanation. The [[:print:]] notation didn't quite work 
either, but following your suggestion I tried \\S- and it worked.

(defun vb-first-printable ()
  (interactive)
  (beginning-of-line)
  ( if (re-search-forward "\\S-" (line-end-position) 't)
      (backward-char)
    )
)


Boy, nothing is what it seems with emacs :-)

cheers,
/vb

On Wednesday 01 November 2006 12:04, Kevin Rodgers wrote:
> vb wrote:
> > let's say I need a function to find first printable character on the line
> > where the pointer is. This is what I'm trying to use:
> >
> > (defun vb-first-printable ()
> >   (interactive)
> >   (let (limit-position)
> >     (beginning-of-line)
> >     (next-line 1)
> >     (setq limit-position (point))
> >     (previous-line 1)
> >     (re-search-forward "\\S" limit-position 't)))
> >
> > when I try executing this, I get the following error:
> >
> > ====================================================
> > Debugger entered--Lisp error: (invalid-regexp "Premature end of regular
> > expression")
> >   re-search-forward("\\S" 3543 t)
> >   (let (limit-position) (beginning-of-line) (next-line 1) (setq
> > limit-position (point)) (previous-line 1) (re-search-forward "\\S"
> > limit-position (quote t)))
> >   vb-first-printable()
> >   call-interactively(vb-first-printable)
> > ===================================================
> >
> > the same problem happens when I try re-search-forward from the command
> > line: if I enter "\S" as the pattern to search, I get "premature end of
> > regular expression" error,  but if I enter "\\S" as the regular
> > expression pattern, the only thing it finds is this pattern (\\S) itself
> > (as I try it on the same file where the source code is).
> >
> > What am I missing here?
>
> Commands that prompt you for a regexp allow you to enter it directly;
> but when calling a Lisp function you have to specify the regexp as a
> string, and in order to represent a backslash within a (double quote-
> delimited) string literal you must double it: "This string has 1
> backslash (here: \\) and 1 double quote (here: \")."  And of course
> the `\\' regexp matches the backslash character itself.
>
> The manual states:
>
> ,----
>
> | `\sC'
> |      matches any character whose syntax is C.  Here C is a character
> |      that designates a particular syntax class: thus, `w' for word
> |      constituent, `-' or ` ' for whitespace, `.' for ordinary
> |      punctuation, etc.  *Note Syntax::.
> |
> | `\SC'
> |      matches any character whose syntax is not C.
>
> `----
>
> So you must specify a syntax class `C', e.g. `w' for word constituent,
> `-' or ` ' for whitespace, `.' for ordinary punctuation, etc.
>
> But as there is no syntax class for printable or non-printable
> characters, that seems like a dead end.  But there is the [:print:]
> character class that you can use in regular expressions.
>
> And finally, all that limit-position/next-line/point/previous-line stuff
> can be replaced by line-end-position:
>
> (defun vb-first-printable ()
>    (interactive)
>    (beginning-of-line)
>    (re-search-forward "[[:print:]]" (line-end-position)))

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

* Re: Regular expression search
  2006-11-01 21:10       ` vb
@ 2006-11-01 22:23         ` Edward O'Connor
  2006-11-01 23:08           ` vb
  2006-11-02 18:49         ` Kevin Rodgers
  1 sibling, 1 reply; 8+ messages in thread
From: Edward O'Connor @ 2006-11-01 22:23 UTC (permalink / raw)


> (defun vb-first-printable ()
> (interactive)
> (beginning-of-line)
> ( if (re-search-forward "\\S-" (line-end-position) 't)
> (backward-char)
> )
> )
>

I wonder if you know about M-m?

,----[ C-h k M-m ]
| M-m runs the command back-to-indentation
|    which is an interactive compiled Lisp function in `simple'.
| (back-to-indentation)
| 
| Move point to the first non-whitespace character on this line.
`----


-- 
Edward O'Connor
hober0@gmail.com

Ense petit placidam sub libertate quietem.

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

* Re: Regular expression search
  2006-11-01 22:23         ` Edward O'Connor
@ 2006-11-01 23:08           ` vb
  0 siblings, 0 replies; 8+ messages in thread
From: vb @ 2006-11-01 23:08 UTC (permalink / raw)
  Cc: Edward O'Connor

On Wednesday 01 November 2006 14:23, Edward O'Connor wrote:
> > (defun vb-first-printable ()
> > (interactive)
> > (beginning-of-line)
> > ( if (re-search-forward "\\S-" (line-end-position) 't)
> > (backward-char)
> > )
> > )
>
> I wonder if you know about M-m?
>

This is a good question - no, I didn't! I suspected there was a command for 
that but did not find it in a brief search.

But it was educational to figure out the emacs regexp search idiosyncrasy 
anyways :-)

cheers,
/vb

> ,----[ C-h k M-m ]
>
> | M-m runs the command back-to-indentation
> |    which is an interactive compiled Lisp function in `simple'.
> | (back-to-indentation)
> |
> | Move point to the first non-whitespace character on this line.
>
> `----

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

* Re: Regular expression search
  2006-11-01 21:10       ` vb
  2006-11-01 22:23         ` Edward O'Connor
@ 2006-11-02 18:49         ` Kevin Rodgers
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2006-11-02 18:49 UTC (permalink / raw)


[Please don't top-post.]

vb wrote:
> thank you for your explanation. The [[:print:]] notation didn't quite work 
> either, but following your suggestion I tried \\S- and it worked.

Ah, the [:foo:] character classes were introduced in Emacs 22.

> (defun vb-first-printable ()
>   (interactive)
>   (beginning-of-line)
>   ( if (re-search-forward "\\S-" (line-end-position) 't)
>       (backward-char)
>     )
> )

(eq t 't) => t

> Boy, nothing is what it seems with emacs :-)

?
-- 
Kevin

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

end of thread, other threads:[~2006-11-02 18:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.7939.1160429872.9609.help-gnu-emacs@gnu.org>
2006-10-10 12:51 ` Where is clipper.el's homepage today? greg.bognar
2006-10-17  7:37 ` Mathias Dahl
2006-11-01 19:31   ` Regular expression search vb
2006-11-01 20:04     ` Kevin Rodgers
2006-11-01 21:10       ` vb
2006-11-01 22:23         ` Edward O'Connor
2006-11-01 23:08           ` vb
2006-11-02 18:49         ` Kevin Rodgers

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.