all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: What's a better regexp for 'sentence-end' variable??
Date: Fri, 21 Feb 2003 19:53:40 +0100	[thread overview]
Message-ID: <u4r6xzevl.fsf@ID-87814.user.dfncis.de> (raw)
In-Reply-To: mailman.2220.1045823872.21513.help-gnu-emacs@gnu.org

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é!

  parent reply	other threads:[~2003-02-21 18:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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
     [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=u4r6xzevl.fsf@ID-87814.user.dfncis.de \
    --to=alkibiades@gmx.de \
    /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.