]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/paragraphs.el
progmodes/cc-menus.el (cc-imenu-c++-generic-expression): Make it handle
[gnu-emacs] / lisp / textmodes / paragraphs.el
index ca141c1b671225625f9ed340624be4515d862009..59454043c4ed45a3ac2967e6baa55978cd783955 100644 (file)
@@ -1,10 +1,11 @@
 ;;; paragraphs.el --- paragraph and sentence parsing
 
-;; Copyright (C) 1985, 1986, 1987, 1991, 1994, 1995, 1996, 1997, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991, 1994-1997, 1999-2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: wp
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
@@ -42,7 +43,7 @@ only considered as a candidate to match `paragraph-start' or
 
 Prefix argument says to turn mode on if positive, off if negative.
 When the mode is turned on, if there are newlines in the buffer but no hard
-newlines, ask the user whether to mark as hard any newlines preceeding a
+newlines, ask the user whether to mark as hard any newlines preceding a
 `paragraph-start' line.  From a program, second arg INSERT specifies whether
 to do this; it can be `never' to change nothing, t or `always' to force
 marking, `guess' to try to do the right thing with no questions, nil
@@ -141,7 +142,7 @@ regexp describing the end of a sentence, when the value of the variable
 (put 'sentence-end-without-period 'safe-local-variable 'booleanp)
 
 (defcustom sentence-end-without-space
-  "\e$B!#!%!)!*\e$A!##.#?#!\e$(0!$!%!)!*\e$(G!$!%!)!*\e(B"
+  "。.?!"
   "String of characters that end sentence without following spaces.
 
 This value is used by the function `sentence-end' to construct the
@@ -163,7 +164,7 @@ to obtain the value of this variable."
   :type '(choice regexp (const :tag "Use default value" nil)))
 (put 'sentence-end 'safe-local-variable 'string-or-null-p)
 
-(defcustom sentence-end-base "[.?!][]\"'\e$B!I\e$,1r}\e(B)}]*"
+(defcustom sentence-end-base "[.?!][]\"')}]*"
   "Regexp matching the basic end of a sentence, not including following space."
   :group 'paragraphs
   :type 'string
@@ -409,7 +410,12 @@ negative arg -N means kill forward to Nth end of paragraph."
   (kill-region (point) (progn (backward-paragraph arg) (point))))
 
 (defun transpose-paragraphs (arg)
-  "Interchange this (or next) paragraph with previous one."
+  "Interchange the current paragraph with the next one.
+With prefix argument ARG a non-zero integer, moves the current
+paragraph past ARG paragraphs, leaving point after the current paragraph.
+If ARG is positive, moves the current paragraph forwards, if
+ARG is negative moves it backwards.  If ARG is zero, exchanges
+the current paragraph with the one containing the mark."
   (interactive "*p")
   (transpose-subr 'forward-paragraph arg))
 
@@ -450,21 +456,25 @@ sentences.  Also, every paragraph boundary terminates sentences as well."
         (sentence-end (sentence-end)))
     (while (< arg 0)
       (let ((pos (point))
-           ;; We used to use (start-of-paragraph-text), but this can
-           ;; prevent sentence-end from matching if it is anchored at
-           ;; BOL and the paragraph starts indented.
-           (par-beg (save-excursion (backward-paragraph) (point))))
-       (if (and (re-search-backward sentence-end par-beg t)
-               (or (< (match-end 0) pos)
-                   (re-search-backward sentence-end par-beg t)))
-          (goto-char (match-end 0))
-        (goto-char par-beg)))
+           (par-beg
+            (save-excursion
+              (start-of-paragraph-text)
+              ;; Move PAR-BEG back over indentation
+              ;; to allow s1entence-end to match if it is anchored at
+              ;; BOL and the paragraph starts indented.
+              (beginning-of-line)
+              (point))))
+       (if (and (re-search-backward sentence-end par-beg t)
+                (or (< (match-end 0) pos)
+                    (re-search-backward sentence-end par-beg t)))
+           (goto-char (match-end 0))
+         (goto-char par-beg)))
       (setq arg (1+ arg)))
     (while (> arg 0)
       (let ((par-end (save-excursion (end-of-paragraph-text) (point))))
-       (if (re-search-forward sentence-end par-end t)
-          (skip-chars-backward " \t\n")
-        (goto-char par-end)))
+       (if (re-search-forward sentence-end par-end t)
+           (skip-chars-backward " \t\n")
+         (goto-char par-end)))
       (setq arg (1- arg)))
     (constrain-to-field nil opoint t)))
 
@@ -509,13 +519,17 @@ ones already marked."
    nil t))
 
 (defun transpose-sentences (arg)
-  "Interchange this (next) and previous sentence."
+  "Interchange the current sentence with the next one.
+With prefix argument ARG a non-zero integer, moves the current
+sentence past ARG sentences, leaving point after the current sentence.
+If ARG is positive, moves the current sentence forwards, if
+ARG is negative moves it backwards.  If ARG is zero, exchanges
+the current sentence with the one containing the mark."
   (interactive "*p")
   (transpose-subr 'forward-sentence arg))
 
 ;; Local Variables:
-;; coding: iso-2022-7bit
+;; coding: utf-8
 ;; End:
 
-;; arch-tag: e727eb1a-527a-4464-b9d7-9d3ec0d1a575
 ;;; paragraphs.el ends here