From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: need help with emacs Date: Fri, 07 Jan 2005 17:41:18 GMT Message-ID: References: <1105074884.110660@sj-nntpcache-3> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1105119545 6390 80.91.229.6 (7 Jan 2005 17:39:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 7 Jan 2005 17:39:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 07 18:38:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Cmy4Q-0000rD-00 for ; Fri, 07 Jan 2005 18:38:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CmyFm-0001LW-UI for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Jan 2005 12:50:26 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:XE2Zc0wlLkVAN/yKvm9/5OL2VZg= Original-Lines: 55 Original-NNTP-Posting-Host: 132.204.24.84 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1105119678 132.204.24.84 (Fri, 07 Jan 2005 12:41:18 EST) Original-NNTP-Posting-Date: Fri, 07 Jan 2005 12:41:18 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:127725 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:23195 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:23195 > I am using TCL in EMACS. What I need right now is the ability to do newline > and indent on a line exceeding 80 characters in addition to adding a \. > e.g. > Suppose I type a line: > This is just an example for lisp in EMACS. This is an example for lisp in > EMACS. This is an example. > This line should be indented as follows: > This is just an example for lisp in EMACS. This is an example for lisp in \ > EMACS. This is an example. > I am not sure if this can be achieved using auto-fill-mode. Maybe someone > among you might be using this or have any idea. You can probably get auto-fill-mode to do something like what you want. You'll probably need something like: (defun my-tcl-comment-line-break-function (&optional soft) (if (tcl-in-string-p) (insert "\\")) (comment-indent-new-line soft)) (defun my-tcl-mode-hook () ...your other Tcl-mode customizations here... (set (make-local-variable 'comment-line-break-function) 'my-tcl-comment-line-break-function)) (add-hook 'tcl-mode-hook 'my-tcl-mode-hook) But tcl-mode does not define tcl-in-string-p. If you use Emacs-CVS (and font-lock), you can try to use (defun tcl-in-string-p () (nth 3 (syntax-ppss))) if not, you can try (defun tcl-in-string-p () (nth 3 (parse-partial-sexp (point-min) (point)))) but that may end up being too slow if you're editing a large Tcl buffer (syntax-ppss is much faster because it uses caching). Another option is something like (defun tcl-in-string-p () (save-excursion (let ((pos (point))) (beginning-of-defun) (nth 3 (parse-partial-sexp (point) pos))))) which should stay reasonably fast. Stefan