* What's a better regexp for 'sentence-end' variable??
@ 2003-02-18 13:16 gebser
0 siblings, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-18 13:16 UTC (permalink / raw)
Hello, all,
Happy snowstorm!
This problem has required some thought and, frankly,I don't think it can
be done-- not without some considerable rewriting of elisp code.
Because I do considerable editing of html and similar types of files, I
wanted to add to the standard definition of "sentence-end". I.e., I
wanted emacs to consider an end of sentence such character sequences
which have ".", "?", or "!" when they are followed by either a "<" or
">".
The standard end-of-sentence variable is defined as:
(defcustom sentence-end (purecopy "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[
\t\n]*")
Initially I thought that just adding the "<" and ">" characters would do
it. I.e.:
(defcustom sentence-end (purecopy "[.?!][]\<>\"')}]*\\($\\| $\\|\t\\|
\\)[ \t\n]*")
(the above should be all on one line) would do this. It doesn't because
I want the cursor to land on top of the ">" or "<" character immediately
after string comprising the standard definition. That is, given:
end.</p>
hitting M-e would place the cursor after the period.
So what's the proper syntax to have emacs see ".", "!", or "?" (and
other expressions defined by the default "sentence-end variable) as the
end of a sentence when one of them is followed by either the ">" or "<"
characters?
The reason I said that I didn't think this could be done simply is
because it seems that emacs would have to search and find strings such
as ".<" or ". <" or "? <" and then back up a character or two or three.
Hope I've been clear enough.
tia,
ken
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
[not found] <mailman.2070.1045574190.21513.help-gnu-emacs@gnu.org>
@ 2003-02-18 14:06 ` Oliver Scholz
2003-02-18 20:15 ` gebser
2003-02-19 18:41 ` gebser
0 siblings, 2 replies; 18+ messages in thread
From: Oliver Scholz @ 2003-02-18 14:06 UTC (permalink / raw)
gebser@ameritech.net writes:
[...]
> Because I do considerable editing of html and similar types of files, I
> wanted to add to the standard definition of "sentence-end". I.e., I
> wanted emacs to consider an end of sentence such character sequences
> which have ".", "?", or "!" when they are followed by either a "<" or
> ">".
[...]
> (defcustom sentence-end (purecopy "[.?!][]\<>\"')}]*\\($\\| $\\|\t\\|
> \\)[ \t\n]*")
What is the `purecopy' in your code good for? You didn't change this
in the source code, did you? ;-)
[...]
> I want the cursor to land on top of the ">" or "<" character immediately
> after string comprising the standard definition. That is, given:
>
> end.</p>
>
> hitting M-e would place the cursor after the period.
I would do it with a simple bit of Elisp. You could put something
like the following into your ~/.emacs:
(defun my-html-forward-sentence ()
(interactive)
(save-match-data
(if (re-search-forward "\\([.?!]\\)<" nil t)
(goto-char (match-end 1))
(goto-char (point-max)))))
(define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
Oliver
--
30 Pluviôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 14:06 ` What's a better regexp for 'sentence-end' variable?? Oliver Scholz
@ 2003-02-18 20:15 ` gebser
2003-02-18 22:32 ` David Kastrup
2003-02-18 22:54 ` Kevin Rodgers
2003-02-19 18:41 ` gebser
1 sibling, 2 replies; 18+ messages in thread
From: gebser @ 2003-02-18 20:15 UTC (permalink / raw)
Oliver,
Thanks very much. That works fairly well. I amended the regexp just a
little bit to include "sentence-end"s which are normal, just a period
etc. and a space.
The question now is how to have this load when emacs loads. I put it in
.emacs, reloaded, and got an error:
Error in init file: Symbol's value as variable is void: sgml-mode-map
This is because it's not in the path. So how do I get it in the path?
Thanks again for your assist,
ken
Oliver Scholz at 15:06 (UTC+0100) on Tue, 18 Feb 2003 said:
= gebser@ameritech.net writes:
= [...]
= > Because I do considerable editing of html and similar types of files, I
= > wanted to add to the standard definition of "sentence-end". I.e., I
= > wanted emacs to consider an end of sentence such character sequences
= > which have ".", "?", or "!" when they are followed by either a "<" or
= > ">".
=
= [...]
= > (defcustom sentence-end (purecopy "[.?!][]\<>\"')}]*\\($\\| $\\|\t\\|
= > \\)[ \t\n]*")
=
= What is the `purecopy' in your code good for? You didn't change this
= in the source code, did you? ;-)
=
= [...]
= > I want the cursor to land on top of the ">" or "<" character immediately
= > after string comprising the standard definition. That is, given:
= >
= > end.</p>
= >
= > hitting M-e would place the cursor after the period.
=
= I would do it with a simple bit of Elisp. You could put something
= like the following into your ~/.emacs:
=
=
= (defun my-html-forward-sentence ()
= (interactive)
= (save-match-data
= (if (re-search-forward "\\([.?!]\\)<" nil t)
= (goto-char (match-end 1))
= (goto-char (point-max)))))
=
= (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
=
=
= Oliver
=
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 20:15 ` gebser
@ 2003-02-18 22:32 ` David Kastrup
2003-02-19 15:38 ` Kai Großjohann
2003-02-18 22:54 ` Kevin Rodgers
1 sibling, 1 reply; 18+ messages in thread
From: David Kastrup @ 2003-02-18 22:32 UTC (permalink / raw)
gebser@ameritech.net writes:
> Oliver,
>
> Thanks very much. That works fairly well. I amended the regexp just a
> little bit to include "sentence-end"s which are normal, just a period
> etc. and a space.
>
> The question now is how to have this load when emacs loads. I put it in
> .emacs, reloaded, and got an error:
>
> Error in init file: Symbol's value as variable is void: sgml-mode-map
>
> This is because it's not in the path. So how do I get it in the
> path?
Uh? Maybe it is only defined in sgml-mode. Then it might help to
write
(eval-after-load 'sgml-mode
(define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence))
You can also use (add-hook sgml-mode-hook ...), but frankly, that
makes it quite more complicated to ensure that sgml-mode-map is
changed just once.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 20:15 ` gebser
2003-02-18 22:32 ` David Kastrup
@ 2003-02-18 22:54 ` Kevin Rodgers
2003-02-19 20:42 ` gebser
1 sibling, 1 reply; 18+ messages in thread
From: Kevin Rodgers @ 2003-02-18 22:54 UTC (permalink / raw)
[Please don't top-post: http://www.aglami.com/tpfaq.html]
gebser@ameritech.net wrote:
> Oliver Scholz at 15:06 (UTC+0100) on Tue, 18 Feb 2003 said:
> = (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
>
> The question now is how to have this load when emacs loads. I put it in
> .emacs, reloaded, and got an error:
>
> Error in init file: Symbol's value as variable is void: sgml-mode-map
>
> This is because it's not in the path.
No it's not.
> So how do I get it in the path?
(eval-after-load "sgml-mode" '(progn ...))
or
(add-hook 'sgml-mode-hook
(lambda () (local-set-key (kbd "M-e") 'my-html-forward-sentence)))
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 22:32 ` David Kastrup
@ 2003-02-19 15:38 ` Kai Großjohann
2003-02-19 15:44 ` David Kastrup
0 siblings, 1 reply; 18+ messages in thread
From: Kai Großjohann @ 2003-02-19 15:38 UTC (permalink / raw)
David Kastrup <dak@gnu.org> writes:
> You can also use (add-hook sgml-mode-hook ...), but frankly, that
> makes it quite more complicated to ensure that sgml-mode-map is
> changed just once.
Why is it desirable to ensure that? I know it's cleaner in a way, but
on the other hand it makes the code very obfuscated, so why bother...
--
A turnip curses Elvis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-19 15:38 ` Kai Großjohann
@ 2003-02-19 15:44 ` David Kastrup
2003-02-19 16:26 ` Kai Großjohann
0 siblings, 1 reply; 18+ messages in thread
From: David Kastrup @ 2003-02-19 15:44 UTC (permalink / raw)
kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> David Kastrup <dak@gnu.org> writes:
>
> > You can also use (add-hook sgml-mode-hook ...), but frankly, that
> > makes it quite more complicated to ensure that sgml-mode-map is
> > changed just once.
>
> Why is it desirable to ensure that? I know it's cleaner in a way, but
> on the other hand it makes the code very obfuscated, so why bother...
define-key is a built-in function.
(define-key KEYMAP KEY DEF)
[...]
If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at
the front of KEYMAP.
In short: your keymaps grow ever longer.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-19 15:44 ` David Kastrup
@ 2003-02-19 16:26 ` Kai Großjohann
0 siblings, 0 replies; 18+ messages in thread
From: Kai Großjohann @ 2003-02-19 16:26 UTC (permalink / raw)
David Kastrup <dak@gnu.org> writes:
> kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
>
>> Why is it desirable to ensure that? I know it's cleaner in a way, but
>> on the other hand it makes the code very obfuscated, so why bother...
>
> In short: your keymaps grow ever longer.
It seems the documentation is wrong:
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (setq k (make-sparse-keymap))
(keymap)
ELISP> (define-key k "a" 'foo)
foo
ELISP> k
(keymap
(97 . foo))
ELISP> (define-key k "a" 'foo)
foo
ELISP> k
(keymap
(97 . foo))
ELISP>
So I guess a doc fix is needed.
--
A turnip curses Elvis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 14:06 ` What's a better regexp for 'sentence-end' variable?? Oliver Scholz
2003-02-18 20:15 ` gebser
@ 2003-02-19 18:41 ` gebser
1 sibling, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-19 18:41 UTC (permalink / raw)
Oliver Scholz at 15:06 (UTC+0100) on Tue, 18 Feb 2003 said:
= gebser@ameritech.net writes:
= [...]
= > Because I do considerable editing of html and similar types of files, I
= > wanted to add to the standard definition of "sentence-end". I.e., I
= > wanted emacs to consider an end of sentence such character sequences
= > which have ".", "?", or "!" when they are followed by either a "<" or
= > ">".
=
= [...]
= > (defcustom sentence-end (purecopy "[.?!][]\<>\"')}]*\\($\\| $\\|\t\\|
= > \\)[ \t\n]*")
=
= What is the `purecopy' in your code good for? You didn't change this
= in the source code, did you? ;-)
Ya got me. That's what's used in paragraphs.el where "sentence-end" is
defined.
=
= [...]
= > I want the cursor to land on top of the ">" or "<" character immediately
= > after string comprising the standard definition. That is, given:
= >
= > end.</p>
= >
= > hitting M-e would place the cursor after the period.
=
= I would do it with a simple bit of Elisp. You could put something
= like the following into your ~/.emacs:
=
=
= (defun my-html-forward-sentence ()
= (interactive)
= (save-match-data
= (if (re-search-forward "\\([.?!]\\)<" nil t)
= (goto-char (match-end 1))
= (goto-char (point-max)))))
This is pretty much what I wanted. Thanks.
=
= (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
This didn't go. An error told me that I don't have the path (to psgml).
I haven't been able to figure that one out yet.
Thanks again,
ken
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-18 22:54 ` Kevin Rodgers
@ 2003-02-19 20:42 ` gebser
0 siblings, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-19 20:42 UTC (permalink / raw)
Hey, guys,
Thanks for all the suggestions. For some reason, though the function
works, none of the commands to assign it to "M-e" have worked:
(require 'sgml-mode) ;before the `define-key'-expression in .emacs
(eval-after-load 'sgml-mode
(define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence))
(add-hook 'sgml-mode-hook
(lambda () (local-set-key (kbd "M-e")
'my-html-forward-sentence)))
(define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
I've tried the first with each of the last four, reloading emacs for
each attempt, and M-e stubbornly remains mapped to the standard
"sentence-end".
Is it possible that something in my .emacs is loading html-helper-mode
after the above and overwriting the key definition?
Regardos,
ken
Kevin Rodgers at 15:54 (UTC-0700) on Tue, 18 Feb 2003 said:
= [Please don't top-post: http://www.aglami.com/tpfaq.html]
=
= gebser@ameritech.net wrote:
=
= > Oliver Scholz at 15:06 (UTC+0100) on Tue, 18 Feb 2003 said:
= > = (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
= >
= > The question now is how to have this load when emacs loads. I put it in
= > .emacs, reloaded, and got an error:
= >
= > Error in init file: Symbol's value as variable is void: sgml-mode-map
= >
= > This is because it's not in the path.
=
= No it's not.
=
= > So how do I get it in the path?
=
= (eval-after-load "sgml-mode" '(progn ...))
=
= or
=
= (add-hook 'sgml-mode-hook
= (lambda () (local-set-key (kbd "M-e") 'my-html-forward-sentence)))
=
=
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
[not found] <un0kr4229.fsf@ID-87814.user.dfncis.de>
@ 2003-02-21 10:37 ` gebser
0 siblings, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-21 10:37 UTC (permalink / raw)
Oliver,
Merci vielmals nochmal for the Beihilfe.
Oliver Scholz at 12:35 (UTC+0100) on Thu, 20 Feb 2003 said:
= gebser@ameritech.net writes:
=
= > Oliver Scholz at 15:06 (UTC+0100) on Tue, 18 Feb 2003 said:
= [...]
= > = What is the `purecopy' in your code good for? You didn't change this
= > = in the source code, did you? ;-)
= >
= > Ya got me. That's what's used in paragraphs.el where "sentence-end" is
= > defined.
=
= It is in general a bad idea to modify the Elisp sources, because it is
= absolutely unnessary, but may lead to trouble. The place to change
= anything on the Lisp level is your .emacs. Even if it would be
= absolutely necessary to change a function's definition (it almost
= never is), you would be better off to copy it into your .emacs and
= change it there.
You're right. But it's the hacker in me that likes to just go in and
change things... why gnu and linux stuff is so cool. I've been doing
this for years and it seems to work for me most of the time. True, it
isn't necessary. But if I copied off every bit of code I changed and
put it in my .emacs, my .emacs would be huge. It's already too big.
I've even cut off large chunks of it and put it into a separate file in
site-lisp, occasionally compiling it. I suppose that would be the best
practice.
The worst part about changing the original is that I lose my changes
when I upgrade. (Actually, I save off the old versions until I can copy
in my personal customizations.)
For this problem I'm putting code into .emacs:
...
; Needed for defun my-html-forward-sentence below
(require 'sgml-mode)
;;Find the end of an html sentence, e.g., "end.</p>".
(defun my-html-forward-sentence ()
(interactive)
(save-match-data
(if (re-search-forward "\\([.?!]\\)[<\t\n ]" nil t)
(goto-char (match-end 1))
(goto-char (point-max)))))
;;The above works... have to do M-x my-html-forward-sentence RETURN
;;Doesn't work. 1
(define-key html-mode-map (kbd "M-e") 'my-html-forward-sentence)
;;Doesn't work. 2
(define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
;; Doesn't work. 3
;(eval-after-load 'sgml-mode
; (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence))
;;Doesn't work. 4
;(add-hook 'sgml-mode-hook
;(lambda () (local-set-key (kbd "M-e") 'my-html-forward-sentence)))
...
I tried each of these, reloading emacs each time. Question: Putting the
cursor after the closing parenthesis of each (1 - 4) and doing C-x C-e
would accomplish the same thing, yes?
=
= If you want to modify `sentence-end' you can simply put something like
= this into your .emacs:
It doesn't back up a character (to get before the '<') like yours does.
=
= (setq sentence-end "Your new regexp")
=
=
= > [modifying `sgml-mode-map']
=
= > This didn't go. An error told me that I don't have the path (to psgml).
= > I haven't been able to figure that one out yet.
= [...]
=
= Psgml is an add-on package that doesn't ship with stock Emacs. What is
= the exakt error message that tells you that psgml is not in the path?
For the life of me, I don't recall how I came to that. I've been trying
to get it back for the past hour+. Maybe I changed something yesterday
which resolved that. And looking below, it seems that psgml is being
loaded now.
= What is the value of `load-path'? (Try `C-h v load-path RET') Where is
= psgml installed?
load-path's value is
("/usr/share/emacs/site-lisp/tramp/lisp/"
"/usr/share/emacs/20.7/site-lisp" "/usr/share/emacs/site-lisp"
"/usr/share/emacs/site-lisp/apel" "/usr/share/emacs/site-lisp/egg"
"/usr/share/emacs/site-lisp/flim" "/usr/share/emacs/site-lisp/lang"
"/usr/share/emacs/site-lisp/mew" "/usr/share/emacs/site-lisp/psgml"
"/usr/share/emacs/site-lisp/semi"
"/usr/share/emacs/site-lisp/site-start.d"
"/usr/share/emacs/site-lisp/tramp"
"/usr/share/emacs/site-lisp/tramp-2.0.28"
"/usr/share/emacs/site-lisp/wl" "/usr/share/emacs/site-lisp/egg/egg"
"/usr/share/emacs/site-lisp/egg/its"
"/usr/share/emacs/site-lisp/tramp/contrib"
"/usr/share/emacs/site-lisp/tramp/info"
"/usr/share/emacs/site-lisp/tramp/lisp"
"/usr/share/emacs/site-lisp/tramp/test"
"/usr/share/emacs/site-lisp/tramp/texi"
"/usr/share/emacs/site-lisp/tramp/tramp2"
"/usr/share/emacs/site-lisp/tramp-2.0.28/contrib"
"/usr/share/emacs/site-lisp/tramp-2.0.28/info"
"/usr/share/emacs/site-lisp/tramp-2.0.28/lisp"
"/usr/share/emacs/site-lisp/tramp-2.0.28/test"
"/usr/share/emacs/site-lisp/tramp-2.0.28/texi"
"/usr/share/emacs/site-lisp/tramp-2.0.28/tramp2"
"/usr/share/emacs/site-lisp/wl/utils" "/usr/share/emacs/20.7/leim"
"/usr/share/emacs/20.7/lisp" "/usr/share/emacs/20.7/lisp/textmodes"
"/usr/share/emacs/20.7/lisp/progmodes" "/usr/share/emacs/20.7/lisp/play"
"/usr/share/emacs/20.7/lisp/mail" "/usr/share/emacs/20.7/lisp/language"
"/usr/share/emacs/20.7/lisp/international"
"/usr/share/emacs/20.7/lisp/gnus" "/usr/share/emacs/20.7/lisp/emulation"
"/usr/share/emacs/20.7/lisp/emacs-lisp"
"/usr/share/emacs/20.7/lisp/calendar" "/usr/share/emacs/site-lisp/psgml"
"/usr/share/emacs/site-lisp/wl")
It looks like psgml being loaded twice.
=
= As I said in my other answer, you probably need to `require' your
= HTML/SGML package before you modify `sgml-mode-map'. If you use
= psgml, you probably have an expression like (require 'psgml) in your
= .emacs. (I am not sure, because I don't use psgml yet.) Make sure that
= the `define-key' part comes _after_ that.
(require 'sgml-mode) ; is what I have there.
Letzte Nachrichten: I pulled this out of the old bag of tricks and it
worked:
(global-set-key "\M-e" 'my-html-forward-sentence)
Yes, I'd prefer that this keybinding be in effect only in buffers using
html-helper-mode (which, I know, is what you're aiming at). But booking
passage there hasn't seemed possible.
Now I need something to fill in the hole in the complement for the
above:
(global-set-key "\M-a" 'my-html-backward-sentence)
something like:
;;Find the begin of a sentence, e.g., "</p>Begin" or ". Begin"
(defun my-html-backward-sentence ()
(interactive)
(save-match-data
(if (re-search-backward "\\(>\\)[ ,AZ]\\|[.?!] " nil t)
(toggle-case-fold-search)
(re-search-forward "\\([A-Z]\\)" nil t))
(forward-char 1)))
This isn't ready for prime time though. Without a supportive
understanding of tags, it'll remain a semi-reliable cludge.
Thanks again for your kind assistance,
ken
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
[not found] <mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org>
@ 2003-02-21 14:40 ` Stefan Monnier <foo@acm.com>
2003-02-21 14:55 ` gebser
2003-02-21 18:53 ` Oliver Scholz
2003-02-21 19:09 ` David Kastrup
2 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2003-02-21 14:40 UTC (permalink / raw)
>>>>> "gebser" == gebser <gebser@ameritech.net> writes:
> The worst part about changing the original is that I lose my changes
> when I upgrade. (Actually, I save off the old versions until I can copy
> in my personal customizations.)
Check out the source from CVS, modify it there, build your own Emacs
and you're set: upgrading is only a `cvs update' away and your
local changes are kept and automatically merged, ...
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-21 14:40 ` Stefan Monnier <foo@acm.com>
@ 2003-02-21 14:55 ` gebser
0 siblings, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-21 14:55 UTC (permalink / raw)
Great. I didn't know this. Guess I need to learn a little more CVS,
especially doing it all from within emacs.
Thanks,
ken
Stefan Monnier <foo@acm.com> at 09:40 (UTC-0500) on 21 Feb 2003 said:
= >>>>> "gebser" == gebser <gebser@ameritech.net> writes:
= > The worst part about changing the original is that I lose my changes
= > when I upgrade. (Actually, I save off the old versions until I can copy
= > in my personal customizations.)
=
= Check out the source from CVS, modify it there, build your own Emacs
= and you're set: upgrading is only a `cvs update' away and your
= local changes are kept and automatically merged, ...
=
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
[not found] <mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org>
2003-02-21 14:40 ` Stefan Monnier <foo@acm.com>
@ 2003-02-21 18:53 ` Oliver Scholz
2003-02-21 19:46 ` gebser
2003-02-21 19:09 ` David Kastrup
2 siblings, 1 reply; 18+ messages in thread
From: Oliver Scholz @ 2003-02-21 18:53 UTC (permalink / raw)
gebser@ameritech.net writes:
[...]
> Oliver Scholz at 12:35 (UTC+0100) on Thu, 20 Feb 2003 said:
[...]
> = It is in general a bad idea to modify the Elisp sources, because it is
> = absolutely unnessary, but may lead to trouble. The place to change
> = anything on the Lisp level is your .emacs.
[...]
> You're right. But it's the hacker in me that likes to just go in and
> change things...
I just wanted to be sure that you know what you are doing. :-)
[It could lead to problems, btw, when doing remote debugging on
usenet, because your Emacs would behave differently from what other
people would expect ... *eg* O.k., o.k., I won't mention it again ... ]
[...]
>
> ;;Doesn't work. 1
> (define-key html-mode-map (kbd "M-e") 'my-html-forward-sentence)
>
> ;;Doesn't work. 2
> (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence)
>
> ;; Doesn't work. 3
> ;(eval-after-load 'sgml-mode
> ; (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence))
^^^
[I think, that should be ...'(define-key ... (Note the quote.)]
> ;;Doesn't work. 4
> ;(add-hook 'sgml-mode-hook
> ;(lambda () (local-set-key (kbd "M-e") 'my-html-forward-sentence)))
> ...
Hmm. Offhand I can think of three reasons. Either ...
... those forms are never evaluated. You could check this by putting a
(progn (message "Huhu!") (sit-for 10))
right before them and then start Emacs again.
... or, as you suggested, they are evaluated, but something changes
the keymap after that.
... or psgml-mode doesn't use `sgml-mode-map'. Maybe `psgml-mode-map'?
>
> I tried each of these, reloading emacs each time. Question: Putting the
> cursor after the closing parenthesis of each (1 - 4) and doing C-x C-e
> would accomplish the same thing, yes?
Yes. You could try that with #1 or #2.
[...]
> load-path's value is
[load-path]
> It looks like psgml being loaded twice.
That's no problem. Emacs takes the first entry in the list, where it
finds the required package.
[...]
> Letzte Nachrichten: I pulled this out of the old bag of tricks and it
> worked:
>
> (global-set-key "\M-e" 'my-html-forward-sentence)
>
> Yes, I'd prefer that this keybinding be in effect only in buffers using
> html-helper-mode (which, I know, is what you're aiming at). But booking
> passage there hasn't seemed possible.
Hmm, I am not familiar with all those SGML/HTML/XML-editing-mode. Is
`html-helper-mode' a package different from psgml? Maybe there is an
`html-helper-mode-map'?
>>
> Now I need something to fill in the hole in the complement for the
> above:
>
> (global-set-key "\M-a" 'my-html-backward-sentence)
>
> something like:
>
> ;;Find the begin of a sentence, e.g., "</p>Begin" or ". Begin"
> (defun my-html-backward-sentence ()
> (interactive)
> (save-match-data
> (if (re-search-backward "\\(>\\)[ ,AZ]\\|[.?!] " nil t)
> (toggle-case-fold-search)
`toggle-case-fold-search' will toggle `case-fold-search' globally,
each time, the search is successful. If you want to bind it to
another value temporarily, use a `let' binding:
(let ((case-fold-search t)) ... )
> (re-search-forward "\\([A-Z]\\)" nil t))
> (forward-char 1)))
I would use the same technique again:
(defun my-html-backward-sentence ()
(interactive)
(save-match-data
(if (re-search-backward ">\\([[:alpha:]\\s-*]\\|[.?!]\\)" nil t)
(goto-char (match-beginning 1)) ; then: go to beginning of
; subexpression 1.
(goto-char (point-min))))) ; else: go to point-min.
Hint: If you want to construct regexps for Emacs Lisp, M-x re-builder
makes this easy. It provides visual feedback on the regexp you are
constructing in the buffer, subexpressions included.
Oliver
--
3 Ventôse an 211 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
[not found] <mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org>
2003-02-21 14:40 ` Stefan Monnier <foo@acm.com>
2003-02-21 18:53 ` Oliver Scholz
@ 2003-02-21 19:09 ` David Kastrup
2 siblings, 0 replies; 18+ messages in thread
From: David Kastrup @ 2003-02-21 19:09 UTC (permalink / raw)
gebser@ameritech.net writes:
> Oliver Scholz at 12:35 (UTC+0100) on Thu, 20 Feb 2003 said:
>
> = It is in general a bad idea to modify the Elisp sources, because it is
> = absolutely unnessary, but may lead to trouble. The place to change
> = anything on the Lisp level is your .emacs. Even if it would be
> = absolutely necessary to change a function's definition (it almost
> = never is), you would be better off to copy it into your .emacs and
> = change it there.
>
> You're right. But it's the hacker in me that likes to just go in
> and change things...
That's not a hacker, that's a fool. Everything will break on the next
upgrade. One does not customize in that manner. While the true
hacker _will_ just go in and change things (but not to customize, but
rather to fix and augment them, or to add customizability), he will
afterwards commit his changes to the CVS archive. That way he does
not need to apply all his work again when he is installing a new
version of Emacs, or installing for a friend of his from the net.
> why gnu and linux stuff is so cool.
Because you can have things break all over the place and keep your
fixes for yourself? No, that wasn't it.
> I've been doing this for years and it seems to work for me most of
> the time.
Have you thought about taking up Russian Roulette as a hobby?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-21 18:53 ` Oliver Scholz
@ 2003-02-21 19:46 ` gebser
2003-02-21 20:56 ` Kai Großjohann
0 siblings, 1 reply; 18+ messages in thread
From: gebser @ 2003-02-21 19:46 UTC (permalink / raw)
You got it!
At 19:53 (UTC+0100) on Fri, 21 Feb 2003 Oliver Scholz said:
= gebser@ameritech.net writes:
= [...]
= >
= > ;; Doesn't work. 3
= > ;(eval-after-load 'sgml-mode
= > ; (define-key sgml-mode-map (kbd "M-e") 'my-html-forward-sentence))
= ^^^
=
= [I think, that should be ...'(define-key ... (Note the quote.)]
That fixed it! Works as expected now. Very good eye!
= [...]
= Hmm, I am not familiar with all those SGML/HTML/XML-editing-mode. Is
= `html-helper-mode' a package different from psgml? Maybe there is an
= `html-helper-mode-map'?
Not that I've been able to find (using "C-h a html-helper-mode-map"
and other things).
=
= >> [...]
=
= I would use the same technique again:
=
= (defun my-html-backward-sentence ()
= (interactive)
= (save-match-data
= (if (re-search-backward ">\\([[:alpha:]\\s-*]\\|[.?!]\\)" nil t)
= (goto-char (match-beginning 1)) ; then: go to beginning of
= ; subexpression 1.
= (goto-char (point-min))))) ; else: go to point-min.
=
= Hint: If you want to construct regexps for Emacs Lisp, M-x re-builder
= makes this easy. It provides visual feedback on the regexp you are
= constructing in the buffer, subexpressions included.
I'll have a go at this later. I've got to spend a little more time on
doing real (paying) work.
Oliver,
Thanks again for everything... very much appreciated. You're magic.
ken
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-21 19:46 ` gebser
@ 2003-02-21 20:56 ` Kai Großjohann
2003-02-22 1:14 ` gebser
0 siblings, 1 reply; 18+ messages in thread
From: Kai Großjohann @ 2003-02-21 20:56 UTC (permalink / raw)
gebser@ameritech.net writes:
> Not that I've been able to find (using "C-h a html-helper-mode-map"
> and other things).
C-h a differs between Emacs and XEmacs. In Emacs, it finds only
commands. Use M-x apropos RET in Emacs.
--
A preposition is not a good thing to end a sentence with.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: What's a better regexp for 'sentence-end' variable??
2003-02-21 20:56 ` Kai Großjohann
@ 2003-02-22 1:14 ` gebser
0 siblings, 0 replies; 18+ messages in thread
From: gebser @ 2003-02-22 1:14 UTC (permalink / raw)
At 21:56 (UTC+0100) on Fri, 21 Feb 2003 Kai Großjohann said:
= gebser@ameritech.net writes:
=
= > Not that I've been able to find (using "C-h a html-helper-mode-map"
= > and other things).
=
= C-h a differs between Emacs and XEmacs. In Emacs, it finds only
= commands. Use M-x apropos RET in Emacs.
That makes a difference. Yes, html-helper-mode-map is there.
Thanks.
ken
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2003-02-22 1:14 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.2070.1045574190.21513.help-gnu-emacs@gnu.org>
2003-02-18 14:06 ` What's a better regexp for 'sentence-end' variable?? Oliver Scholz
2003-02-18 20:15 ` gebser
2003-02-18 22:32 ` David Kastrup
2003-02-19 15:38 ` Kai Großjohann
2003-02-19 15:44 ` David Kastrup
2003-02-19 16:26 ` Kai Großjohann
2003-02-18 22:54 ` Kevin Rodgers
2003-02-19 20:42 ` gebser
2003-02-19 18:41 ` gebser
[not found] <mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org>
2003-02-21 14:40 ` Stefan Monnier <foo@acm.com>
2003-02-21 14:55 ` gebser
2003-02-21 18:53 ` Oliver Scholz
2003-02-21 19:46 ` gebser
2003-02-21 20:56 ` Kai Großjohann
2003-02-22 1:14 ` gebser
2003-02-21 19:09 ` David Kastrup
[not found] <un0kr4229.fsf@ID-87814.user.dfncis.de>
2003-02-21 10:37 ` gebser
2003-02-18 13:16 gebser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).