text-modes / xrdb-mode.el

Diff from to

xrdb-mode.el

 ;;; xrdb-mode.el --- mode for editing X resource database files
 
-;; Author:        1994-1997 Barry A. Warsaw
+;; Copyright (C) 1998 Free Software Foundation, Inc.
+
+;; Author:        1994-1998 Barry A. Warsaw
 ;; Maintainer:    tools-help@python.org
 ;; Created:       May 1994
 ;; Keywords:      data languages
 
-(defconst xrdb-version "2.11"
+(defconst xrdb-version "2.24"
   "`xrdb-mode' version number.")
 
-;; Copyright (C) 1994 Barry A. Warsaw
+;; This file is part of GNU Emacs.
 
-;; This file is not 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.
 
-;; 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 of the License, or
-;; (at your option) any later version.
-;; 
-;; This program is distributed in the hope that it will be useful,
+;; 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 this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;; 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:
 ;;
 ;; This file provides a major mode for editing X resource database
-;; files, and includes font-lock definitions and commands for
+;; files.  It includes font-lock definitions and commands for
 ;; controlling indentation, re-indenting by subdivisions, and loading
 ;; and merging into the the resource database.
 ;;
 ;;                 ("*.\\.ad$"         . xrdb-mode)
 ;;                 )
 ;;               auto-mode-alist))
+;;
+;; Emacs 19 users will probably have to add the following to their
+;; .emacs file:
+;;
+;;(defadvice char-after (before c-char-after-advice
+;;			      (&optional pos)
+;;			      activate preactivate)
+;;  "POS is optional and defaults to the position of point."
+;;  (if (not pos)
+;;      (setq pos (point))))
 
 ;;; History:
 ;;
 ;; I have fallen from grace and have been kicked out of paradise.  So
 ;; has Steve Jobs apparently :-)
 ;;
-;; The database merge feature was inspired by Joel N. Webber, II.
+;; The database merge feature was inspired by Joel N. Weber II.
+;;
+;; The canonical Web site for xrdb-mode is
+;; <http://www.python.org/emacs/>
 
 ;; Code:
 
                delimiters.
 
  `page'      - All lines in the page are scanned.  Pages are delimited 
-               with `page-delimiter', usual ^L (control-L).
+               with `page-delimiter', usually ^L (control-L).
 
  `line'      - Only the previous non-comment line is scanned.  This is
                the fastest method.
 
-This variable is consulted from `xrdb-indent-region' and
-`xrdb-indent-buffer' and can be overridden in both commands."
+This variable is used by the various indentation commands, and can be
+overridden in those commands by using \\[universal-argument]."
   :type '(radio (const :tag "Do not subdivide buffer" buffer)
 		(const :tag "Subdivide by paragraphs" paragraph)
 		(const :tag "Subdivide by pages" page)
 
 
 ;; utilities
-(defsubst xrdb-point (position)
+(defun xrdb-point (position)
   ;; Returns the value of point at certain commonly referenced POSITIONs.
   ;; POSITION can be one of the following symbols:
   ;; 
 	  (indent-line-to 0)))
     ))
 
+
 (defun xrdb-indent-line (&optional arg)
   "Align the current line with the nearest previous non-comment line.
-With universal argument \\[universal-argument], insert just a TAB."
+With optional \\[universal-argument], insert just a TAB."
   (interactive "P")
   (if arg
       (insert "\t")
 
 (defun xrdb-indent-region (start end &optional arg)
   "Indent all lines in the region according to `xrdb-subdivide-by'.
-With optional numeric argument, prompt for subdivision."
+With optional \\[universal-argument], prompt for subdivision."
   (interactive "r\nP")
   (xrdb-align-to-column
    (xrdb-guess-goal-column (if arg
 			     xrdb-subdivide-by))
    start end))
 
-(defun xrdb-indent-page ()
-  "Indent all lines in the page according to `xrdb-subdivide-by'."
-  (interactive)
+(defun xrdb-indent-page (&optional arg)
+  "Indent all lines in the page according to `xrdb-subdivide-by'.
+With optional \\[universal-argument], prompt for subdivision."
+  (interactive "P")
   (xrdb-align-to-column
-   (xrdb-guess-goal-column 'page)
+   (xrdb-guess-goal-column (if arg
+			       (xrdb-prompt-for-subdivision)
+			     xrdb-subdivide-by))
    (xrdb-point 'bopg)
    (xrdb-point 'eopg)))
 
-(defun xrdb-indent-paragraph ()
-  "Indent all lines in the paragraph according to `xrdb-subdivide-by'."
-  (interactive)
+(defun xrdb-indent-paragraph (&optional arg)
+  "Indent all lines in the paragraph according to `xrdb-subdivide-by'.
+With optional \\[universal-argument], prompt for subdivision."
+  (interactive "P")
   (xrdb-align-to-column
-   (xrdb-guess-goal-column 'paragraph)
+   (xrdb-guess-goal-column (if arg
+			       (xrdb-prompt-for-subdivision)
+			     xrdb-subdivide-by))
    (xrdb-point 'bop)
    (xrdb-point 'eop)))
 
 (defun xrdb-indent-buffer (&optional arg)
   "Indent all lines in the buffer according to `xrdb-subdivide-by'.
-With optional numeric argument, prompt for subdivision."
+With optional \\[universal-argument], prompt for subdivision."
   (interactive "P")
   (let ((subdivide-by (if arg
 			  (xrdb-prompt-for-subdivision)
   (define-key xrdb-mode-map "\C-c\C-a" 'xrdb-indent-buffer)
   (define-key xrdb-mode-map "\C-c\C-b" 'xrdb-submit-bug-report)
   (define-key xrdb-mode-map "\C-c\C-c" 'xrdb-database-merge-buffer-or-region)
-  (define-key xrdb-mode-map "\C-c\C-f" 'xrdb-indent-paragraph)
-  (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-page)
+  (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-paragraph)
+  (define-key xrdb-mode-map "\C-c\["   'xrdb-indent-page)
   (define-key xrdb-mode-map "\C-c\C-r" 'xrdb-indent-region)
   )
 
 ;; merging and manipulating the X resource database
 (defun xrdb-database-merge-buffer-or-region (start end)
   "Merge the current buffer's resources into the X resource database.
+
 `xrdb-program' is the program to actually call, with the arguments
-specified in `xrdb-program-args'.  This latter can be set to do either 
+specified in `xrdb-program-args'.  This latter can be set to do either
 a merge or a load, etc.  Also, if the file local variable
 `xrdb-master-file' is non-nil, then it is merged instead of the
 buffer's file.
    ;; will be nil, if not passed in programmatically
    (list (xrdb-safe (and (mark) (region-beginning)))
 	 (xrdb-safe (and (mark) (region-end)))))
+  (message "Merging...")
   (let ((outbuf (get-buffer-create "*Shell Command Output*")))
     ;; I prefer the XEmacs way of doing this, but this is the easiest
     ;; way to work in both XEmacs and Emacs.
       (apply 'call-process-region (point-min) (point-max) xrdb-program
 	     nil outbuf t xrdb-program-args)))
     (if (not (zerop (with-current-buffer outbuf (buffer-size))))
-	(pop-to-buffer outbuf))))
+	(pop-to-buffer outbuf)))
+  (message "Merging... done"))
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.