all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* newbie elisp question
@ 2005-09-08  1:59 B. T. Raven
  2005-09-08  2:20 ` Drew Adams
  2005-09-08  4:19 ` Pascal Bourguignon
  0 siblings, 2 replies; 7+ messages in thread
From: B. T. Raven @ 2005-09-08  1:59 UTC (permalink / raw)



With the following forms in my .emacs, which the *scratch* buffer
evaluates without complaint, (from which I infer that they are at least
syntactically correct)

(defconst *vowels* '(?a ?e ?i ?o ?u ?y)
  "A list of the English vowels in lowercase.")

...
(defun vowelp (char)
  (memq (downcase char) *vowels*))

(defun goto-vowel
"Skip to next vowel after point."
(interactive)
(while (not (vowelp (char-after))) (forward-char))
)

(define-key global-map [f11] 'goto-vowel)

...

I get this error message:

"call-interactively: Invalid function: (lambda "Skip to next vowel after
point." (interactive) (while (not (vowelp (char-after)))
(forward-char)))"

What am I not understanding here?

Thanks,

Ed

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

* RE: newbie elisp question
  2005-09-08  1:59 newbie elisp question B. T. Raven
@ 2005-09-08  2:20 ` Drew Adams
  2005-09-08  4:19 ` Pascal Bourguignon
  1 sibling, 0 replies; 7+ messages in thread
From: Drew Adams @ 2005-09-08  2:20 UTC (permalink / raw)


    With the following forms in my .emacs, which the *scratch* buffer
    evaluates without complaint, (from which I infer that they are at least
    syntactically correct)
    
    (defconst *vowels* '(?a ?e ?i ?o ?u ?y)
      "A list of the English vowels in lowercase.")
    
    ...
    (defun vowelp (char)
      (memq (downcase char) *vowels*))
    
    (defun goto-vowel
    "Skip to next vowel after point."
    (interactive)
    (while (not (vowelp (char-after))) (forward-char))
    )
    
    (define-key global-map [f11] 'goto-vowel)
    
    ...
    
    I get this error message:
    
    "call-interactively: Invalid function: (lambda "Skip to next vowel after
    point." (interactive) (while (not (vowelp (char-after)))
    (forward-char)))"
    
    What am I not understanding here?

Your function is missing an argument list. It should have the empty list after the command name:

    (defun goto-vowel ()
     ...)

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

* Re: newbie elisp question
  2005-09-08  1:59 newbie elisp question B. T. Raven
  2005-09-08  2:20 ` Drew Adams
@ 2005-09-08  4:19 ` Pascal Bourguignon
  2005-09-08 22:40   ` B. T. Raven
  1 sibling, 1 reply; 7+ messages in thread
From: Pascal Bourguignon @ 2005-09-08  4:19 UTC (permalink / raw)


"B. T. Raven" <ecinmn@peoplepc.com> writes:
> [...]
> (defun goto-vowel
> "Skip to next vowel after point."
> (interactive)
> (while (not (vowelp (char-after))) (forward-char))
> )
> [...]
> What am I not understanding here?

Drew answered why.

I'll add that you could use looking-at:

(defun goto-vowel ()
 "Skip to next vowel after point."
 (interactive)
 (while (not (looking-at "[aeiouy]") (forward-char)))

More over, only in iso-8859-1 there are a lot of other vowels:
 
    ÀÁÂÃÄÅÆÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜÝàáâãäåæèéêëìíîïòóôõöøùúûüýÿ

(and what about semi-vowels like y? In some languages it's considered
a plain vowel).




One would hope to be able to use the character categories and match \C1 as in:

    (while (looking-at "\\C1") (forward-char))

unfortunately, in the default category table, the consonant/vowel
attribute is not set for ASCII characters.  You'd have to build a
correct category table.


-- 
__Pascal_Bourguignon__               _  Software patents are endangering
()  ASCII ribbon against html email (o_ the computer industry all around
/\  1962:DO20I=1.100                //\ the world http://lpf.ai.mit.edu/
    2001:my($f)=`fortune`;          V_/   http://petition.eurolinux.org/

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

* Re: newbie elisp question
  2005-09-08  4:19 ` Pascal Bourguignon
@ 2005-09-08 22:40   ` B. T. Raven
  2005-09-09  0:08     ` Pascal Bourguignon
  0 siblings, 1 reply; 7+ messages in thread
From: B. T. Raven @ 2005-09-08 22:40 UTC (permalink / raw)



"Pascal Bourguignon" <spam@mouse-potato.com> wrote in message
news:87k6hsdwdf.fsf@thalassa.informatimago.com...
> "B. T. Raven" <ecinmn@peoplepc.com> writes:
> > [...]
> > (defun goto-vowel
> > "Skip to next vowel after point."
> > (interactive)
> > (while (not (vowelp (char-after))) (forward-char))
> > )
> > [...]
> > What am I not understanding here?
>
> Drew answered why.
>
> I'll add that you could use looking-at:
>
> (defun goto-vowel ()
>  "Skip to next vowel after point."
>  (interactive)
>  (while (not (looking-at "[aeiouy]") (forward-char)))

Why the quotes? Is this acceptable reg-exp syntax?


>
> More over, only in iso-8859-1 there are a lot of other vowels:
>
>     ÀÁÂÃÄÅÆÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜÝàáâãäåæèéêëìíîïòóôõöøùúûüýÿ
>
> (and what about semi-vowels like y? In some languages it's considered
> a plain vowel).
>
>
>
>
> One would hope to be able to use the character categories and match
\C1 as in:
>
>     (while (looking-at "\\C1") (forward-char))
>
> unfortunately, in the default category table, the consonant/vowel
> attribute is not set for ASCII characters.  You'd have to build a
> correct category table.

Which sounds like it might not be the right job for a newbie who could
commit such a boner as leaving the parentheses off after a defun
definition. Anyway, thanks, Drew and Pascal. I didn't even know about
the looking-at function but I guess I'll use it now instead even though
I don't need the power of regular expressions for my application.
I did include 'y' as a vowel in my defconst, which is what I wanted
here. Btw, supplying the missing parens after the defun uncovers another
error: bad type passed to memq. Calling forward-char before the loop
seems to fix this, I know not why.
I don't need any of the common European diacriticals but I do use
macroned vowels (y excepted, since it doesn't exist in any of the more
prepossessing fonts, as far as I know. The macroned vowels (Latin 4)
require that the file be saved as a utf-8 since there are sometimes
Greek and Hebrew characters in the same file. Which leads to my final
question: Has anyone here successfully copypasted from a utf-8 buffer to
another Windows application that supports Unicode? My emacs is a w32
build (21.3) and I can only accomplish the transfer of arbitrary unicode
strings by saving to a file as utf-8, opening or inserting the file
(encoded text) with Open Office, and then copypasting from there. Any
ideas?

Thanks again,

Ed

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

* Re: newbie elisp question
  2005-09-08 22:40   ` B. T. Raven
@ 2005-09-09  0:08     ` Pascal Bourguignon
  2005-09-09 16:28       ` B. T. Raven
  0 siblings, 1 reply; 7+ messages in thread
From: Pascal Bourguignon @ 2005-09-09  0:08 UTC (permalink / raw)


"B. T. Raven" <ecinmn@peoplepc.com> writes:
>> (defun goto-vowel ()
>>  "Skip to next vowel after point."
>>  (interactive)
>>  (while (not (looking-at "[aeiouy]") (forward-char)))
>
> Why the quotes? Is this acceptable reg-exp syntax?

I don't see any quote in this function. quote = '
I see four double-quotes that delimit two strings. double-quote = "
There are also a pair of brackets = [] inside one of this strings, which is
a regexp syntax to mean any of the characters inside the brackets.

> Which leads to my final
> question: Has anyone here successfully copypasted from a utf-8 buffer to
> another Windows application that supports Unicode? My emacs is a w32
> build (21.3) and I can only accomplish the transfer of arbitrary unicode
> strings by saving to a file as utf-8, opening or inserting the file
> (encoded text) with Open Office, and then copypasting from there. Any
> ideas?

It should be enough to configure the encodings. Something like this in
~/.emacs:

        (set-language-environment               'UTF-8)
        (set-default-coding-systems             'utf-8)
        (setq file-name-coding-system           'utf-8)
        (setq default-buffer-file-coding-system 'utf-8)
        (setq coding-system-for-write           'utf-8)
        (set-keyboard-coding-system             'utf-8)
        (set-terminal-coding-system             'utf-8)
        (set-clipboard-coding-system            'utf-8)
        (set-selection-coding-system            'utf-8)
        (prefer-coding-system                   'utf-8)
        (modify-coding-system-alist 'process "\\*shell\\*\\'" 'utf-8-unix)

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Litter box not here.
You must have moved it again.
I'll poop in the sink. 

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

* Re: newbie elisp question
  2005-09-09  0:08     ` Pascal Bourguignon
@ 2005-09-09 16:28       ` B. T. Raven
  2005-09-09 17:32         ` Pascal Bourguignon
  0 siblings, 1 reply; 7+ messages in thread
From: B. T. Raven @ 2005-09-09 16:28 UTC (permalink / raw)



"Pascal Bourguignon" <spam@mouse-potato.com> wrote in message
news:87r7bzayse.fsf@thalassa.informatimago.com...
> "B. T. Raven" <ecinmn@peoplepc.com> writes:
> >> (defun goto-vowel ()
> >>  "Skip to next vowel after point."
> >>  (interactive)
> >>  (while (not (looking-at "[aeiouy]") (forward-char)))
> >
> > Why the quotes? Is this acceptable reg-exp syntax?
>
> I don't see any quote in this function. quote = '
> I see four double-quotes that delimit two strings. double-quote = "
> There are also a pair of brackets = [] inside one of this strings,
which is
> a regexp syntax to mean any of the characters inside the brackets.
>

I was using the word 'quote' here generically and too loosely for the
context, as if one were to say bang for exclamation point where it might
mean, for example "logical not." Anyway, the substance of my
animadversion was wrong-headed, as I realized as soon as I sent it out.
The reason is that I have never used regular expressions
programatically, only interactively.

> > Which leads to my final
> > question: Has anyone here successfully copypasted from a utf-8
buffer to
> > another Windows application that supports Unicode? My emacs is a w32
> > build (21.3) and I can only accomplish the transfer of arbitrary
unicode
> > strings by saving to a file as utf-8, opening or inserting the file
> > (encoded text) with Open Office, and then copypasting from there.
Any
> > ideas?
>
> It should be enough to configure the encodings. Something like this in
> ~/.emacs:
>
>         (set-language-environment               'UTF-8)
>         (set-default-coding-systems             'utf-8)
>         (setq file-name-coding-system           'utf-8)
>         (setq default-buffer-file-coding-system 'utf-8)
>         (setq coding-system-for-write           'utf-8)
>         (set-keyboard-coding-system             'utf-8)
>         (set-terminal-coding-system             'utf-8)
>         (set-clipboard-coding-system            'utf-8)
>         (set-selection-coding-system            'utf-8)
>         (prefer-coding-system                   'utf-8)
>         (modify-coding-system-alist 'process "\\*shell\\*\\'"
'utf-8-unix)

I had tried all of these before except the last line. Using  (under
Win98)

 (modify-coding-system-alist 'process "[cC][mM][dD][pP][rR][oO][xX][yY]"
'utf-8-unix)

I still get garbage when trying to copypaste Unicode. I think I want to
set this back to undecided-dos, though, or I am afraid I'll have
problems with the different end of line conventions. I guess I'll try
your suggestion on another w32 emacs  21.3 that I have installed on
Win2000 system.

Thanks anyway,

Ed.


>
> --
> __Pascal Bourguignon__
http://www.informatimago.com/
> Litter box not here.
> You must have moved it again.
> I'll poop in the sink.

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

* Re: newbie elisp question
  2005-09-09 16:28       ` B. T. Raven
@ 2005-09-09 17:32         ` Pascal Bourguignon
  0 siblings, 0 replies; 7+ messages in thread
From: Pascal Bourguignon @ 2005-09-09 17:32 UTC (permalink / raw)



"B. T. Raven" <ecinmn@peoplepc.com> writes:
>>         (set-clipboard-coding-system            'utf-8)
>>         (set-selection-coding-system            'utf-8)
>
> I still get garbage when trying to copypaste Unicode. I think I want to
> set this back to undecided-dos, though, or I am afraid I'll have
> problems with the different end of line conventions. I guess I'll try
> your suggestion on another w32 emacs  21.3 that I have installed on
> Win2000 system.

Well this works on X on unix...


-- 
"What is this talk of "release"?  Klingons do not make software
"releases".  Our software "escapes" leaving a bloody trail of
designers and quality assurance people in its wake."

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

end of thread, other threads:[~2005-09-09 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-08  1:59 newbie elisp question B. T. Raven
2005-09-08  2:20 ` Drew Adams
2005-09-08  4:19 ` Pascal Bourguignon
2005-09-08 22:40   ` B. T. Raven
2005-09-09  0:08     ` Pascal Bourguignon
2005-09-09 16:28       ` B. T. Raven
2005-09-09 17:32         ` Pascal Bourguignon

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.