all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "gamename" <namesagame-usenet@yahoo.com>
Subject: Re: setting continuation chars
Date: 8 Jul 2006 01:47:59 -0700	[thread overview]
Message-ID: <1152348479.679623.224700@m73g2000cwd.googlegroups.com> (raw)
In-Reply-To: <mailman.3529.1151613525.9609.help-gnu-emacs@gnu.org>

Thanks Jay!

-T


Jay Bingham wrote:
> > 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
> ;;;;##################################################################
> ##
> ######
>
> ;;;=======<Variable>=======<Variable>=======<Variable>=======<Variable
> >=
> ======
> (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
> ;;;;##################################################################
> ##
> ######
>
> ;;========<Function>=======<Function>=======<Function>=======<Function
> >=
> ======
> ;; 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))
>
> ;;========<Function>=======<Function>=======<Function>=======<Function
> >=
> ======
> ;; 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

       reply	other threads:[~2006-07-08  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3529.1151613525.9609.help-gnu-emacs@gnu.org>
2006-07-08  8:47 ` gamename [this message]
2006-06-29 20:35 setting continuation chars Jay Bingham
  -- strict thread matches above, loose matches on Subject: below --
2006-06-28 19:20 gamename
2006-06-29  7:38 ` Mathias Dahl
2006-06-29 11:24   ` gamename

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=1152348479.679623.224700@m73g2000cwd.googlegroups.com \
    --to=namesagame-usenet@yahoo.com \
    /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.