From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Jay Bingham" Newsgroups: gmane.emacs.help Subject: RE: setting continuation chars Date: Thu, 29 Jun 2006 20:35:31 GMT Message-ID: <20060629.133624.21820.249205@webmail10.nyc.untd.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1151613544 2883 80.91.229.2 (29 Jun 2006 20:39:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Jun 2006 20:39:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 29 22:38:59 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fw3Hu-0006Ij-7K for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jun 2006 22:38:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fw3Ht-0002gD-P7 for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jun 2006 16:38:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fw3Hf-0002fG-R8 for help-gnu-emacs@gnu.org; Thu, 29 Jun 2006 16:38:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fw3He-0002eV-Bs for help-gnu-emacs@gnu.org; Thu, 29 Jun 2006 16:38:43 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fw3He-0002eO-8m for help-gnu-emacs@gnu.org; Thu, 29 Jun 2006 16:38:42 -0400 Original-Received: from [64.136.20.164] (helo=outbound-mail.nyc.untd.com) by monty-python.gnu.org with smtp (Exim 4.52) id 1Fw3UG-000410-LP for help-gnu-emacs@gnu.org; Thu, 29 Jun 2006 16:51:44 -0400 Original-Received: from webmail10.nyc.untd.com (webmail10.nyc.untd.com [10.141.27.150]) by smtpout02.nyc.untd.com with SMTP id AABCLJQSDA5RZYR2 for (sender ); Thu, 29 Jun 2006 13:37:23 -0700 (PDT) Original-Received: (from b.jc-emacs@netzero.com) by webmail10.nyc.untd.com (jqueuemail) id LT3E6SZ8; Thu, 29 Jun 2006 13:36:24 PDT Original-Received: from [15.235.153.107] by webmail10.nyc.untd.com with HTTP: Thu, 29 Jun 2006 20:35:31 GMT X-Originating-IP: [15.235.153.107] Original-To: help-gnu-emacs@gnu.org X-Mailer: Webmail Version 4.0 Content-Disposition: inline X-ContentStamp: 90:45:4288371438 X-MAIL-INFO: 48002d0821010c21bda5014c414cc9cce9783c6ccca1fc15fca1e56cb1b16ccd6c0879 X-UNTD-OriginStamp: 9wMZ3l1+FG1mkmIQefRR9m5aYb8QGUX9Izl8QKOsEr+YMNk7sYy0YwrpQiLEZJzv X-UNTD-Peer-Info: 10.141.27.150|webmail10.nyc.untd.com|webmail10.nyc.untd.com|b.jc-emacs@netzero.com 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: news.gmane.org gmane.emacs.help:35734 Archived-At: > 2) use some sort of command (regex?) to insert the needed spaces up = to > a certain column and then put in a backslash? You got my curiosity up. So I went looking and found that there is a = function called move-to-column that will move to the column given as = an argument. That inspired me to write a little package (see the = text following my signature) that contains a function that will = insert the line continuation character in a specified column when it = is invoked. The package assigns a key "C-return" to the function continue-line. To use the package you just need to put it in a file called continue- line.el and put that in your load path. Everything else that you = need to know should be contained in the comments and descriptions in = the package. __ J_) C_)ingham ;;; continue-line.el --- continue a line based on the major mode ;;-------------------------------------------------------------------- -- ------- ;; Last Modified Time-stamp: <29Jun2006 14:33:50 CDT by JCBingham> ;;-------------------------------------------------------------------- -- ------- ;; Copyright (C) 2006 JCBingham ;; ;; Author: b.jc-emacs@netzero.com ;; Version: $Id: continue-line.el,v 0.01 2006/06/29 17:01:35 JCBingham Exp $ ;; Keywords: mode based line continuation ;; Requirements: Emacs-21.3 or higher ;; Status: not intended to be distributed yet ;; X-URL: not distributed yet ;; This program is free software; you can redistribute it and/or = modify ;; it under the terms of the GNU General Public License as published = by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; This package provides the capability to continue a line based on = the major ;; mode with the line continuation character or characters in the same column. ;; ;; The user configurable variables in this package are: ;; cli-mode-continuation-str ;; cli-targ ;; ;; The interactive functions in this package are: ;; continue-line ;; ;; The keys defined in this package are: ;; C-return set to continue-line ;; To load this package in all your emacs sessions put this file into your ;; load-path and put the following line (without the comment = delimiter) ;; into your ~/.emacs: ;; (require 'continue-line) ;; To auto-load this package in your emacs sessions (loaded only when needed) ;; put this file into your load-path and put the following lines (without the ;; comment delimiters) into your ~/.emacs: ;; (autoload ' continue-line "continue-line" ;; "Continue a line based on the major mode that is active in the buffer." ;; t nil) ;; (autoload ' set-continue-column "continue-line" ;; "Set the continuation character column for the continue-line function." ;; t nil) ;;;++ Module History ++ ;; 29 Jun 2006 - JCBingham - ;; Initial version containing the following - ;; user configurable variables: ;; cli-mode-continuation-str ;; cli-targ ;; ;; interactive functions: ;; continue-line ;; set-continue-column ;; ;; keys defined: ;; C-return set to continue-line ;;;-- Module History end -- ;;; Code: (provide 'continue-line) ;;;;################################################################## ## ###### ;;;; Customizable Package Variables ;;;;################################################################## ## ###### ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D (defvar cli-mode-continuation-str '((makefile-mode . "\\") (sh-mode . "\\") (tcl-mode . "\\")) "An a-list containing the continuation string for modes that use = them. Each element of the list is an associated pair of the mode name and = the string that will be inserted by the continue-line function when that mode is active. The default values can be overridden by placing the sexp \(setq cli-mode-continuation-str '\(\(makefile-mode . \"\\\\\"\) \(sh-mode . \"\\\\\"\) \(tcl-mode . \"\\\\\"\)\) in your .emacs file and changing the backslashes to the desired characters. It should be noted that all of the emacs string constraints apply. Hence to insert a single backslash two are required. After the package is loaded the list can be manipulated using any of = the elisp list manipulation functions. Adding an element to the front of the = list with the same car as an element already in the list will cause later = element to be superseded." ) (defvar cli-targ 79 "The starting column for the line continuation string. This is an integer variable specifying the column in which the continue-line function will begin inserting the line continuation string. The value should be positive but is not required to be since the function uses the absolute value of the variable. It is a buffer-local variable. The default value can be overridden by placing the sexp \(setq cli-targ nn\) where nn is the desired column number in your .emacs file." ) (make-variable-buffer-local 'cli-targ) ;;;;################################################################## ## ###### ;;;; Interactive Functions ;;;;################################################################## ## ###### ;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D ;; Function: continue-line ;; ;; Psuedo code: ;; if no prefix argument was specified ;; then set the target column to the default target value ;; set the target column to the absolute value of itself ;; if there is a continuation string defined for the mode ;; then ;; if the target column is greater than the current column ;; then ;; insert spaces/tabs until the cursor is in the specified column ;; else ;; insert a single space ;; insert the continuation string ;; insert a carriage return ;; indent according to the major mode in effect ;; (defun continue-line (&optional targ) "Continue a line based on the major mode that is active in the = buffer. If there is a continuation string defined for the mode, insert spaces/tabs until the cursor is in the specified column (unless the current column is at or beyond the target column, in which case insert a single space) insert the continuation string. Insert a carriage return, indent according to the major mode in effect. When invoked with a prefix argument the absolute value of the argument is used as the target column. When invoked without a prefix argument the = target column is obtained from the variable cli-targ. cli-targ is a buffer local variable." (interactive "*P") (if (not targ) (setq targ cli-targ)) (setq targ (abs targ)) (when (cdr (assoc major-mode cli-mode-continuation-str)) (if (> targ (current-column)) (move-to-column targ t) (insert " ")) (insert (cdr (assoc major-mode cli-mode-continuation-str)))) (insert "\n") (indent-according-to-mode)) ;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D ;; Function: set-continue-column ;; ;; Psuedo code: ;; if the argument is greater than 0 ;; then ;; set the default target value to the argument ;; else ;; issue an error message ;; return nil ;; (defun set-continue-column (val) "Set the continuation character column for the continue-line = function. The column number must be greater than 0." (interactive "p") (if (> val 0) (setq cli-targ val) (message "Argument greater than 0 is required") nil)) (global-set-key [C-return] 'continue-line) ;;; END OF continue-line.el _____________________________________________________________________ PrivatePhone - FREE telephone number & voicemail. A number so private, you can make it public. http://www.privatephone.com _____________________________________________________________________ PrivatePhone - FREE telephone number & voicemail. A number so private, you can make it public. http://www.privatephone.com