all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: gebser@ameritech.net
Subject: Re: What's a better regexp for 'sentence-end' variable??
Date: Fri, 21 Feb 2003 05:37:45 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0302201728140.16795-100000@heidegger.mousecar.net> (raw)
In-Reply-To: <un0kr4229.fsf@ID-87814.user.dfncis.de>


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

       reply	other threads:[~2003-02-21 10:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <un0kr4229.fsf@ID-87814.user.dfncis.de>
2003-02-21 10:37 ` gebser [this message]
     [not found] <mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org>
2003-02-21 14:40 ` What's a better regexp for 'sentence-end' variable?? 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] <mailman.2070.1045574190.21513.help-gnu-emacs@gnu.org>
2003-02-18 14:06 ` 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
2003-02-18 13:16 gebser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0302201728140.16795-100000@heidegger.mousecar.net \
    --to=gebser@ameritech.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.