From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: gebser@ameritech.net Newsgroups: gmane.emacs.help Subject: Re: What's a better regexp for 'sentence-end' variable?? Date: Fri, 21 Feb 2003 05:37:45 -0500 (EST) Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: Reply-To: gebser@ameritech.net NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1045823973 12636 80.91.224.249 (21 Feb 2003 10:39:33 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 21 Feb 2003 10:39:33 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18mAaY-0003Hg-00 for ; Fri, 21 Feb 2003 11:39:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18mAZE-0002LH-02 for gnu-help-gnu-emacs@m.gmane.org; Fri, 21 Feb 2003 05:38:08 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18mAYv-0002HH-00 for help-gnu-emacs@gnu.org; Fri, 21 Feb 2003 05:37:49 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18mAYt-0002FY-00 for help-gnu-emacs@gnu.org; Fri, 21 Feb 2003 05:37:48 -0500 Original-Received: from mailhost2-bcvloh.bcvloh.ameritech.net ([66.73.20.44] helo=mailhost.bcv2.ameritech.net) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18mAYs-0002F0-00 for help-gnu-emacs@gnu.org; Fri, 21 Feb 2003 05:37:46 -0500 Original-Received: from heidegger.mousecar.net ([65.43.209.47]) by mailhost.bcv2.ameritech.net (InterMail vM.4.01.02.17 201-229-119) with ESMTP <20030221103744.UNKV366.mailhost.bcv2.ameritech.net@heidegger.mousecar.net> for ; Fri, 21 Feb 2003 05:37:44 -0500 Original-To: help-gnu-emacs@gnu.org In-Reply-To: X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6972 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6972 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.

". (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., "

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