Use line-end-position rather than end-of-line, etc.
[bpt/emacs.git] / lisp / textmodes / page-ext.el
index 2afaafd..548223e 100644 (file)
@@ -1,16 +1,18 @@
 ;;; page-ext.el --- extended page handling commands
 
-;; Copyright (C) 1990, 1991, 1993, 1994 Free Software Foundation
+;; Copyright (C) 1990, 1991, 1993, 1994, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
-;; Maintainer: Robert J. Chassell <bob@gnu.org>
+;; Author: Robert J. Chassell <bob@gnu.org>
+;; (according to ack.texi)
 ;; Keywords: wp data
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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.
+;; the Free Software Foundation, either version 3 of the License, 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
@@ -18,9 +20,7 @@
 ;; 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.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;;
 ;;     FSF
 ;;     Free Software Foundation
-;;     59 Temple Place - Suite 330
-;;     Boston, MA 02111-1307  USA.
+;;     51 Franklin Street, Fifth Floor
+;;     Boston, MA 02110-1301  USA.
 ;;     (617) 542-5942
 ;;     gnu@gnu.org
 ;;
 
 
 (defcustom pages-directory-buffer-narrowing-p t
-  "*If non-nil, `pages-directory-goto' narrows pages buffer to entry."
+  "If non-nil, `pages-directory-goto' narrows pages buffer to entry."
   :type 'boolean
   :group 'pages)
 
 (defcustom pages-directory-for-adding-page-narrowing-p t
-  "*If non-nil, `add-new-page' narrows page buffer to new entry."
+  "If non-nil, `add-new-page' narrows page buffer to new entry."
   :type 'boolean
   :group 'pages)
 
 (defcustom pages-directory-for-adding-new-page-before-current-page-p t
-  "*If non-nil, `add-new-page' inserts new page before current page."
+  "If non-nil, `add-new-page' inserts new page before current page."
   :type 'boolean
   :group 'pages)
 
 ;;; Addresses related variables
 
 (defcustom pages-addresses-file-name "~/addresses"
-  "*Standard name for file of addresses. Entries separated by page-delimiter.
+  "Standard name for file of addresses. Entries separated by page-delimiter.
 Used by `pages-directory-for-addresses' function."
   :type 'file
   :group 'pages)
 
 (defcustom pages-directory-for-addresses-goto-narrowing-p t
-  "*If non-nil, `pages-directory-goto' narrows addresses buffer to entry."
+  "If non-nil, `pages-directory-goto' narrows addresses buffer to entry."
   :type 'boolean
   :group 'pages)
 
 (defcustom pages-directory-for-addresses-buffer-keep-windows-p t
-  "*If nil, `pages-directory-for-addresses' deletes other windows."
+  "If nil, `pages-directory-for-addresses' deletes other windows."
   :type 'boolean
   :group 'pages)
 
 (defcustom pages-directory-for-adding-addresses-narrowing-p t
-  "*If non-nil, `add-new-page' narrows addresses buffer to new entry."
+  "If non-nil, `add-new-page' narrows addresses buffer to new entry."
   :type 'boolean
   :group 'pages)
 
@@ -507,7 +507,7 @@ resets the page-delimiter to the original value."
   (if (not reset-p)
       (setq page-delimiter regexp)
     (setq page-delimiter original-page-delimiter))
-  (if (interactive-p)
+  (if (called-interactively-p 'interactive)
       (message "The value of `page-delimiter' is now: %s" page-delimiter)))
 
 \f
@@ -565,7 +565,7 @@ directory for only the accessible portion of the buffer."
       (setq regexp pages-directory-previous-regexp)
     (setq pages-directory-previous-regexp regexp))
 
-  (if (interactive-p)
+  (if (called-interactively-p 'interactive)
       (message "Creating directory for: %s "
                (buffer-name)))
 
@@ -580,8 +580,7 @@ directory for only the accessible portion of the buffer."
     ;; `standard-output' to the buffer named as its first argument,
     ;; but does not switch to that buffer.
     (with-output-to-temp-buffer pages-directory-buffer
-      (save-excursion
-        (set-buffer standard-output)
+      (with-current-buffer standard-output
         (pages-directory-mode)
         (insert
          "==== Pages Directory: use `C-c C-c' to go to page under cursor. ====" ?\n)
@@ -633,7 +632,7 @@ directory for only the accessible portion of the buffer."
       (set-buffer standard-output)
       ;; Put positions in increasing order to go with buffer.
       (setq pages-pos-list (nreverse pages-pos-list))
-      (if (interactive-p)
+      (if (called-interactively-p 'interactive)
           (message "%d matching lines in: %s"
                    (length pages-pos-list) (buffer-name pages-target-buffer))))
     (pop-to-buffer pages-directory-buffer)
@@ -641,10 +640,10 @@ directory for only the accessible portion of the buffer."
     (forward-line (if (= 0 pages-buffer-original-page)
                       1
                     pages-buffer-original-page))))
-(eval-when-compile
-  (defvar pages-buffer-original-position)
-  (defvar pages-buffer-original-page)
-  (defvar pages-buffer-original-page))
+
+(defvar pages-buffer-original-position)
+(defvar pages-buffer-original-page)
+(defvar pages-buffer-original-page)
 
 (defun pages-copy-header-and-position (count-lines-p)
   "Copy page header and its position to the Pages Directory.
@@ -672,7 +671,7 @@ Used by `pages-directory' function."
       (setq position (make-marker))
       (set-marker position (point))
       (let ((start (point))
-            (end (save-excursion (end-of-line) (point)))
+            (end (line-end-position))
            inserted-at)
         ;; change to directory buffer
         (set-buffer standard-output)
@@ -736,8 +735,7 @@ to the same line in the pages buffer."
 (defun pages-directory-goto-with-mouse  (event)
   "Go to the corresponding line under the mouse pointer in the pages buffer."
   (interactive "e")
-  (save-excursion
-    (set-buffer (window-buffer (posn-window (event-end event))))
+  (with-current-buffer (window-buffer (posn-window (event-end event)))
     (save-excursion
       (goto-char (posn-point (event-end event)))
       (pages-directory-goto))))
@@ -765,7 +763,7 @@ directory."
    (list (if current-prefix-arg
              (read-file-name "Filename: " pages-addresses-file-name))))
 
-  (if (interactive-p)
+  (if (called-interactively-p 'interactive)
       (message "Creating directory for: %s "
                (or filename pages-addresses-file-name)))
   (if (file-exists-p (or filename pages-addresses-file-name))
@@ -776,14 +774,16 @@ directory."
            (or filename pages-addresses-file-name))))
         (widen)
         (pages-directory t nil nil)
-        (pages-directory-address-mode)
+        ;; by RJC, 2006 Jun 11: including this causes failure; it results in
+        ;;  the message "Buffer in which pages were found is deleted"
+        ;;        (pages-directory-address-mode)
         (setq pages-directory-buffer-narrowing-p
               pages-directory-for-addresses-goto-narrowing-p)
         (or pages-directory-for-addresses-buffer-keep-windows-p
             (delete-other-windows))
         (save-excursion
           (goto-char (point-min))
-          (delete-region (point) (save-excursion (end-of-line) (point)))
+          (delete-region (point) (line-end-position))
           (insert
            "=== Address List Directory: use `C-c C-c' to go to page under cursor. ===")
           (set-buffer-modified-p nil)
@@ -801,5 +801,4 @@ to the same line in the pages buffer."
 
 (provide 'page-ext)
 
-;;; arch-tag: 2f311550-c6e0-4458-9c12-7f039c058bdb
 ;;; page-ext.el ends here