From af372af632bb21749e858350200e13b3e9c10057 Mon Sep 17 00:00:00 2001 From: Dave Love Date: Sat, 23 Oct 1999 18:18:03 +0000 Subject: [PATCH] *** empty log message *** --- lisp/ChangeLog | 4 + lisp/elide-head.el | 116 +++++++++++++++++++ man/ChangeLog | 6 + man/autotype.texi | 277 +++++++++++++++++++++++++++++++++++++-------- 4 files changed, 358 insertions(+), 45 deletions(-) create mode 100644 lisp/elide-head.el diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8402bea63d..4880d20a68 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +1999-10-23 Dave Love + + * elide-head.el: New file. + 1999-10-23 Gerd Moellmann * Makefile (compile-files, backup-compiled-files): New targets. diff --git a/lisp/elide-head.el b/lisp/elide-head.el new file mode 100644 index 0000000000..db26eb8f9e --- /dev/null +++ b/lisp/elide-head.el @@ -0,0 +1,116 @@ +;;; elid-head.el --- hide headers in files + +;; Copyright (C) 1999 Free Software Foundation, Inc. + +;; Author: Dave Love +;; Keywords: outlines tools + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Functionality for eliding boilerplate text (normally copyright +;; notices) in file headers to avoid clutter when you know what it +;; says. +;; +;; `elide-head-headers-to-hide' controls what is elided by the command +;; `elide-head'. A buffer-local invisible overlay manages the +;; elision. + +;; Please don't turn this on in site init files so that information +;; isn't hidden from users who may not know what it says. + +;; Inspired by jwz's hide-copyleft.el, for which we don't have an +;; assignment. + +;;; Code: + +(defgroup elide-head nil + "Eliding copyright headers and the like in source files." + :prefix "elide-head" + :group 'tools) + +(defcustom elide-head-headers-to-hide + '(("is free software; you can redistribute it" . ; GNU boilerplate + "Boston, MA 02111-1307, USA\\.") + ("The Regents of the University of California\\. All rights reserved\\." . + "SUCH DAMAGE\\.") ; BSD + ("Permission is hereby granted, free of charge" . ; X11 + "authorization from the X Consortium\\.")) + "Alist of regexps defining start end end of text to elide. + +The cars of elements of the list are searched for in order. Text is +elided with an invisible overlay from the end of the line where the +first match is found to the end of the match for the corresponding +cdr." + :group 'elide-head + :type '(alist :key-type (string :tag "Start regexp") + :value-type (string :tag "End regexp"))) + +(defvar elide-head-overlay nil) +(make-variable-buffer-local 'elide-head-overlay) + +;;;###autoload +(defun elide-head (&optional arg) + "Hide header material in buffer according to `elide-head-headers-to-hide'. + +The header is made invisible with an overlay. With a prefix arg, show +an elided material again. + +This is suitable as an entry on `find-file-hooks' or appropriate mode hooks." + (interactive "P") + (if arg + (elide-head-show) + (save-excursion + (save-restriction + (let ((rest elide-head-headers-to-hide) + beg end) + (widen) + (goto-char (point-min)) + (while rest + (save-excursion + (when (re-search-forward (caar rest) nil t) + (setq beg (point)) + (when (re-search-forward (cdar rest) nil t) + (setq end (point) + rest nil)))) + (if rest (setq rest (cdr rest)))) + (if (not (and beg end)) + (if (interactive-p) + (error "No header found")) + (goto-char beg) + (end-of-line) + (if (overlayp elide-head-overlay) + (move-overlay elide-head-overlay (point) end) + (setq elide-head-overlay (make-overlay (point) end))) + (overlay-put elide-head-overlay 'invisible t) + (overlay-put elide-head-overlay 'intangible t) + (overlay-put elide-head-overlay 'after-string "..."))))))) + +(defun elide-head-show () + "Show a header elided current buffer by \\[elide-head]." + (interactive) + (if (and (overlayp elide-head-overlay) + (overlay-buffer elide-head-overlay)) + (delete-overlay elide-head-overlay) + (if (interactive-p) + (error "No header hidden")))) + +(provide 'elide-head) + +;;; elide-head.el ends here diff --git a/man/ChangeLog b/man/ChangeLog index 82c431dcc5..3d1013785e 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,3 +1,9 @@ +1999-10-23 Dave Love + + * autotype.texi: New file. + + * Makefile.in: Use it. + 1999-10-23 Paul Eggert * mule.texi, cmdargs.texi: diff --git a/man/autotype.texi b/man/autotype.texi index 4a6574dc54..ad1bfd9a9f 100644 --- a/man/autotype.texi +++ b/man/autotype.texi @@ -1,12 +1,15 @@ -@c This is part of the Emacs manual. +\input texinfo +@c This is an annex of the Emacs manual. @c Copyright (C) 1994, 1995 Free Software Foundation, Inc. @c Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 @c See file emacs.texi for copying conditions. -@node Autotypist, Picture, Abbrevs, Top -@chapter Features for Automatic Typing -@cindex text -@cindex selfinserting text -@cindex autotypist +@setfilename ../info/autotype +@c @node Autotypist, Picture, Abbrevs, Top +@c @chapter Features for Automatic Typing +@settitle Features for Automatic Typing +@c @cindex text +@c @cindex selfinserting text +@c @cindex autotypist @dircategory Editors @direntry @@ -14,11 +17,36 @@ in Emacs. @end direntry +@ifinfo +Copyright @copyright{} 1994, 1995, 1999 Free Software Foundation, Inc. +@end ifinfo + + +@titlepage +@sp 10 + +@center @titlefont{Autotyping} +@sp 2 +@center @subtitlefont{Convenient features for text that you enter +frequently in Emacs} +@sp 2 +@center Daniel Pfeiffer +@center additions by Dave Love + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1994, 1995, 1999 Free Software Foundation, Inc. +@end titlepage + +@node Top +@top Autotyping + Under certain circumstances you will find yourself typing similar things over and over again. This is especially true of form letters and programming language constructs. Project-specific header comments, flow-control constructs or magic numbers are essentially the same every time. Emacs has -various features for doing tedious and repetitive typing chores for you. +various features for doing tedious and repetitive typing chores for you +in addition to the Abbrev features (@pxref{(emacs)Abbrevs}). One solution is using skeletons, flexible rules that say what to insert, and how to do it. Various programming language modes offer some @@ -30,23 +58,38 @@ depending on the file-name or the mode as appropriate. You can have a file or a skeleton inserted, or you can call a function. Then there is the possibility to have Un*x interpreter scripts automatically take on a magic number and be executable as soon as they are saved. Or you can have a -copyright notice's year updated, if necessary, every time you save a file. +copyright notice's year updated, if necessary, every time you save a +file. Similarly for time stamps in the file. + + URLs can be inserted based on a word at point. Flexible templates can +be defined for inserting and navigating between text more generally. A +sort of meta-expansion facility can be used to try a set of alternative +completions and expansions of text at point. @menu * Using Skeletons:: How to insert a skeleton into your text. * Wrapping Skeletons:: Putting existing text within a skeleton. * Skeletons as Abbrevs:: An alternative for issuing skeleton commands. * Skeleton Language:: Making skeleton commands insert what you want. -* Inserting Pairs:: Typing one character and getting another after point. +* Inserting Pairs:: Typing one character and getting another + after point. * Autoinserting:: Filling up empty files as soon as you visit them. * Copyrights:: Inserting and updating copyrights. * Executables:: Turning interpreter scripts into executables. +* Timestamps:: Updating dates and times in modified files. +* QuickURL:: Inserting URLs based on text at point. +* Tempo:: Flexible template insertion. +* Hippie Expand:: Expansion of text trying various methods. + +* Concept Index:: +* Command Index:: +* Variable Index:: @end menu @node Using Skeletons -@section Using Skeletons +@chapter Using Skeletons @cindex skeletons @cindex using skeletons @@ -54,9 +97,10 @@ copyright notice's year updated, if necessary, every time you save a file. programming language you are using, skeletons are a means of accomplishing this. Normally skeletons each have a command of their own, that, when called, will insert the skeleton. These commands can be issued in the usual ways -(@xref{Commands}). Modes that offer various skeletons will often bind these -to key-sequences on the @kbd{C-c} prefix, as well as having an @cite{Insert} -menu and maybe even predefined abbrevs for them (@xref{Skeletons as Abbrevs}). +(@xref{(emacs)Commands}). Modes that offer various skeletons will often +bind these to key-sequences on the @kbd{C-c} prefix, as well as having +an @cite{Insert} menu and maybe even predefined abbrevs for them +(@xref{Skeletons as Abbrevs}). The simplest kind of skeleton will simply insert some text indented according to the major mode and leave the cursor at a likely place in the @@ -75,7 +119,7 @@ termination still gets inserted. @node Wrapping Skeletons -@section Wrapping Skeletons Around Existing Test +@chapter Wrapping Skeletons Around Existing Text @cindex wrapping skeletons Often you will find yourself with some code that for whatever reason @@ -85,18 +129,18 @@ accomplishing this, and can even, in the case of programming languages, reindent the wrapped code for you. Skeleton commands take an optional numeric prefix argument -(@xref{Arguments}). This is interpreted in two different ways depending +(@xref{(emacs)Arguments}). This is interpreted in two different ways depending on whether the prefix is positive, i.e. forwards oriented or negative, i.e. backwards oriented. - A positive prefix means to wrap the skeleton around that many following -words. This is accomplished by putting the words there where the point is -normally left after that skeleton is inserted (@xref{Using Skeletons}). The -point (@xref{Point}) is left at the next interesting spot in the skeleton -instead. + A positive prefix means to wrap the skeleton around that many +following words. This is accomplished by putting the words there where +the point is normally left after that skeleton is inserted (@xref{Using +Skeletons}). The point (@xref{(emacs)Point}) is left at the next +interesting spot in the skeleton instead. A negative prefix means to do something similar with that many precedingly -marked interregions (@xref{Mark}). In the simplest case, if you type +marked interregions (@xref{(emacs)Mark}). In the simplest case, if you type @kbd{M--} just before issuing the skeleton command, that will wrap the skeleton around the current region, just like a positive argument would have wrapped it around a number of words. @@ -124,12 +168,12 @@ tried to follow the order in which you marked these points. @node Skeletons as Abbrevs -@section Skeletons as Abbrev Expansions +@chapter Skeletons as Abbrev Expansions @cindex skeletons as abbrevs - Rather than use a keybinding for every skeleton command, you can also define -an abbreviation (@xref{Defining Abbrevs}) that will expand (@xref{Expanding -Abbrevs}) into the skeleton. + Rather than use a keybinding for every skeleton command, you can also +define an abbreviation (@xref{(emacs)Defining Abbrevs}) that will expand +(@xref{(emacs)Expanding Abbrevs}) into the skeleton. Say you want @samp{ifst} to be an abbreviation for the C language if statement. You will tell Emacs that @samp{ifst} expands to the empty string @@ -149,7 +193,7 @@ have been omitted.) @node Skeleton Language -@section Skeleton Language +@chapter Skeleton Language @cindex skeleton language @findex skeleton-insert @@ -228,12 +272,12 @@ skeleton. The first argument is the command name, the second is a documentation string, and the rest is an interactor and any number of skeleton elements together forming a skeleton. This skeleton is assigned to a variable of the same name as the command and can thus be overridden from your -@file{~/.emacs} file (@xref{Init File}). +@file{~/.emacs} file (@xref{(emacs)Init File}). @node Inserting Pairs -@section Inserting Matching Pairs of Characters +@chapter Inserting Matching Pairs of Characters @cindex inserting pairs @cindex pairs @@ -247,12 +291,13 @@ fingers backwards, this can be quite relieving too. @findex pair-insert-maybe @vindex pair - This is done by binding the first key (@xref{Rebinding}) of the pair to -@code{pair-insert-maybe} instead of @code{self-insert-command}. The maybe -comes from the fact that this at first surprising behaviour is initially -turned off. To enable it, you must set @code{pair} to some non-@code{nil} -value. And even then, a positive argument (@xref{Arguments}) will make this -key behave like a self inserting key (@xref{Inserting Text}). + This is done by binding the first key (@xref{(emacs)Rebinding}) of the +pair to @code{pair-insert-maybe} instead of @code{self-insert-command}. +The maybe comes from the fact that this at first surprising behaviour is +initially turned off. To enable it, you must set @code{pair} to some +non-@code{nil} value. And even then, a positive argument +(@xref{(emacs)Arguments}) will make this key behave like a self +inserting key (@xref{(emacs)Inserting Text}). @findex pair-on-word While this breaks with the stated intention of always balancing pairs, it @@ -279,7 +324,7 @@ in certain contexts. For example an escaped character will stand for itself. @node Autoinserting -@section Autoinserting Text in Empty Files +@chapter Autoinserting Text in Empty Files @cindex autoinserting @findex auto-insert @@ -287,8 +332,8 @@ in certain contexts. For example an escaped character will stand for itself. the buffer. The main application for this function, as its name suggests, is to have it be called automatically every time an empty, and only an empty file is visited. This is accomplished by putting @code{(add-hook -'find-file-hooks 'auto-insert)} into your @file{~/.emacs} file (@xref{Init -File}). +'find-file-hooks 'auto-insert)} into your @file{~/.emacs} file +(@xref{(emacs)Init File}). @vindex auto-insert-alist What gets inserted, if anything, is determined by the variable @@ -324,11 +369,11 @@ files insert a skeleton with the usual frame. files insert the usual header, with a copyright of your environment variable @code{$ORGANIZATION} or else the FSF, and prompt for valid keywords describing the contents. Files in a @code{bin/} directory for which Emacs could -determine no specialised mode (@xref{Choosing Modes}) are set to Shell script +determine no specialised mode (@xref{(emacs)Choosing Modes}) are set to Shell script mode. @findex define-auto-insert - In Lisp (@xref{Init File}) you can use the function @code{define-auto-insert} + In Lisp (@xref{(emacs)Init File}) you can use the function @code{define-auto-insert} to add to or modify @code{auto-insert-alist}. See its documentation with @kbd{C-h f auto-insert-alist}. @@ -363,14 +408,14 @@ expression that matched the filename. @node Copyrights -@section Inserting and Updating Copyrights +@chapter Inserting and Updating Copyrights @cindex copyrights @findex copyright @kbd{M-x copyright} is a skeleton inserting command, that adds a copyright notice at the point. The ``by'' part is taken from your environment variable @code{$ORGANIZATION} or if that isn't set you are prompted for it. If the -buffer has a comment syntax (@xref{Comments}), this is inserted as a comment. +buffer has a comment syntax (@xref{(emacs)Comments}), this is inserted as a comment. @findex copyright-update @vindex copyright-limit @@ -382,13 +427,13 @@ existing ones, in the same format as the preceding year, i.e. 1994, '94 or 94. If a dash-separated year list up to last year is found, that is extended to current year, else the year is added separated by a comma. Or it replaces them when this is called with a prefix argument. If a header referring to a -wrong version of the GNU General Public License (@xref{Copying}) is found, +wrong version of the GNU General Public License (@xref{(emacs)Copying}) is found, that is updated too. An interesting application for this function is to have it be called automatically every time a file is saved. This is accomplished by putting @code{(add-hook 'write-file-hooks 'copyright-update)} into your @file{~/.emacs} -file (@xref{Init File}). +file (@xref{(emacs)Init File}). @vindex copyright-query The variable @code{copyright-query} controls whether to update the @@ -401,7 +446,7 @@ you are always queried. @node Executables -@section Making Interpreter Scripts Executable +@chapter Making Interpreter Scripts Executable @cindex executables @vindex executable-prefix @@ -415,7 +460,7 @@ system @code{chmod} command. The magic number is prefixed by the value of @code{executable-prefix}. @vindex executable-magicless-file-regexp - Any file whos name matches @code{executable-magicless-file-regexp} is not + Any file whose name matches @code{executable-magicless-file-regexp} is not furnished with a magic number, nor is it made executable. This is mainly intended for resource files, which are only meant to be read in. @@ -446,3 +491,145 @@ mode. Otherwise you are alway queried. will turn it into a self displaying text file, when called as a Un*x command. The ``interpreter'' used is @code{executable-self-display} with argument @code{+2}. + +@node Timestamps +@chapter Maintaining Timestamps in Modified Files +@cindex timestamps + +@findex time-stamp +@vindex write-file-hooks +The @code{time-stamp} command can be used to update automatically a +template in a file with a new time stamp every time you save the file. +Customize the hook @code{write-file-hooks} to add the function +@code{time-stamp} to arrange this. + +@vindex time-stamp-active +@vindex time-stamp-format +@vindex time-stamp-start +The time stamp is updated only if the customizable variable +@code{time-stamp-active} is on, which it is by default; the command +@code{time-stamp-toggle-active} can be used to toggle it. The format of +the time stamp is set by the customizable variable +@code{time-stamp-format}. + +@vindex time-stamp-line-limit +@vindex time-stamp-end +@vindex time-stamp-count +@vindex time-stamp-inserts-lines +The variables @code{time-stamp-line-limit}, @code{time-stamp-start}, +@code{time-stamp-end}, @code{time-stamp-count}, and +@code{time-stamp-inserts-lines} control finding the template. Do not +change these in your init file or you will be incompatible with other +people's files. If you must change them, do so only in the local +variables section of the file itself. + +Normally the template must appear in the first 8 lines of a file and +look like one of the following: + +@example +Time-stamp: <> +Time-stamp: " " +@end example + +The time stamp is written between the brackets or quotes: + +@example +Time-stamp: <1998-02-18 10:20:51 gildea> +@end example + +@node QuickURL +@chapter QuickURL: Inserting URLs Based on Text at Point + +@vindex quickurl-url-file +@findex quickurl +@cindex URLs +@kbd{M-x quickurl} can be used to insert a URL into a buffer based on +the text at point. The URLs are stored in an external file defined by +the variable @code{quickurl-url-file} as a list of either cons cells of +the form @code{(@var{key} . @var{URL})} or +lists of the form @code{(@var{key} @var{URL} @var{comment})}. These +specify that @kbd{M-x quickurl} should insert @var{URL} if the word +@var{key} is at point, for example: + +@example +(("FSF" "http://www.fsf.org/" "The Free Software Foundation") + ("emacs" . "http://www.emacs.org/") + ("hagbard" "http://www.hagbard.demon.co.uk" "Hagbard's World")) +@end example + +@findex quickurl-add-url +@findex quickurl-list +@kbd{M-x quickurl-add-url} can be used to add a new @var{key}/@var{URL} +pair. @kbd{M-x quickurl-list} provides interactive editing of the URL +list. + +@node Tempo +@chapter Tempo: Flexible Template Insertion + +@cindex templates +The Tempo package provides a simple way to define powerful templates, or +macros, if you wish. It is mainly intended for, but not limited to, +other programmers to be used for creating shortcuts for editing +certain kinds of documents. + +@findex tempo-backward-mark +@findex tempo-forward-mark +A template is defined as a list of items to be inserted in the current +buffer at point. Some can be simple strings, while others can control +formatting or define special points of interest in the inserted text. +@kbd{M-x tempo-backward-mark} and @kbd{M-x tempo-forward-mark} can be +used to jump between such points. + +More flexible templates can be created by including lisp symbols, which +will be evaluated as variables, or lists, which will will be evaluated +as lisp expressions. Automatic completion of specified tags to expanded +templates can be provided. + +@findex tempo-define-template +See the documentation for @code{tempo-define-template} for the different +items that can be used to define a tempo template with a command for +inserting it. + +See the commentary in @file{tempo.el} for more information on using the +Tempo package. + +@node Hippie Expand +@chapter `Hippie' Expansion + +@findex hippie-expand +@kindex M-/ +@vindex hippie-expand-try-functions-list +@kbd{M-x hippie-expand} is a single command providing a variety of +completions and expansions. Called repeatedly, it tries all possible +completions in succession. + +Which ones to try, and in which order, is determined by the contents of +the customizable option @code{hippie-expand-try-functions-list}. Much +customization of the expansion behaviour can be made by changing the +order of, removing, or inserting new functions in this list. Given a +positive numeric argument, @kbd{M-x hippie-expand} jumps directly that +number of functions forward in this list. Given some other argument (a +negative argument or just @kbd{C-u}) it undoes the tried completion. + +See the commentary in @file{hippie-exp.el} for more information on the +possibilities. + +Typically you would bind @code{hippie-expand} to @kbd{M-/} with +@code{dabbrev-expand}, the standard binding of @kbd{M-/}, providing one +of the expansion possibilities. + + +@node Concept Index +@unnumbered Concept Index +@printindex cp + +@node Command Index +@unnumbered Command Index +@printindex fn + +@node Variable Index +@unnumbered Variable Index +@printindex vr + +@contents +@bye -- 2.20.1