emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109923: Add a utility function buffe


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109923: Add a utility function buffer-narrowed-p, and use it.
Date: Fri, 07 Sep 2012 16:58:31 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109923
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Fri 2012-09-07 16:58:31 +0800
message:
  Add a utility function buffer-narrowed-p, and use it.
  
  * lisp/subr.el (buffer-narrowed-p): New function.
  
  * lisp/ses.el (ses-widen):
  * lisp/simple.el (count-words--buffer-message):
  * lisp/net/browse-url.el (browse-url-of-buffer): Use it
  
  * lisp/simple.el (count-words-region): Don't signal an error if there
  is a non-nil prefix arg and the mark is not set.
  
  * doc/lispref/positions.texi (Narrowing): Document buffer-narrowed-p.
modified:
  doc/lispref/ChangeLog
  doc/lispref/positions.texi
  etc/NEWS
  lisp/ChangeLog
  lisp/emacs-lisp/cl-loaddefs.el
  lisp/net/browse-url.el
  lisp/ses.el
  lisp/simple.el
  lisp/subr.el
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-09-07 04:51:26 +0000
+++ b/doc/lispref/ChangeLog     2012-09-07 08:58:31 +0000
@@ -1,5 +1,7 @@
 2012-09-07  Chong Yidong  <address@hidden>
 
+       * positions.texi (Narrowing): Document buffer-narrowed-p.
+
        * markers.texi (Moving Markers): Add xref to Point (Bug#7151).
 
        * syntax.texi (Low-Level Parsing): Add xref to Parser State

=== modified file 'doc/lispref/positions.texi'
--- a/doc/lispref/positions.texi        2012-09-02 04:47:28 +0000
+++ b/doc/lispref/positions.texi        2012-09-07 08:58:31 +0000
@@ -874,18 +874,18 @@
 remains addressable is called the @dfn{accessible portion} of the
 buffer.
 
-  Narrowing is specified with two buffer positions which become the
-beginning and end of the accessible portion.  For most editing commands
-and most Emacs primitives, these positions replace the values of the
-beginning and end of the buffer.  While narrowing is in effect, no text
-outside the accessible portion is displayed, and point cannot move
-outside the accessible portion.
-
-  Values such as positions or line numbers, which usually count from the
-beginning of the buffer, do so despite narrowing, but the functions
-which use them refuse to operate on text that is inaccessible.
-
-  The commands for saving buffers are unaffected by narrowing; they save
+  Narrowing is specified with two buffer positions, which become the
+beginning and end of the accessible portion.  For most editing
+commands and primitives, these positions replace the values of the
+beginning and end of the buffer.  While narrowing is in effect, no
+text outside the accessible portion is displayed, and point cannot
+move outside the accessible portion.  Note that narrowing does not
+alter actual buffer positions (@pxref{Point}); it only determines
+which positions are considered the accessible portion of the buffer.
+Most functions refuse to operate on text that is outside the
+accessible portion.
+
+  Commands for saving buffers are unaffected by narrowing; they save
 the entire buffer regardless of any narrowing.
 
   If you need to display in a single buffer several very different
@@ -924,6 +924,11 @@
 @end example
 @end deffn
 
address@hidden buffer-narrowed-p
+This function returns address@hidden if the buffer is narrowed, and
address@hidden otherwise.
address@hidden defun
+
 @defspec save-restriction address@hidden
 This special form saves the current bounds of the accessible portion,
 evaluates the @var{body} forms, and finally restores the saved bounds,

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-09-06 09:29:32 +0000
+++ b/etc/NEWS  2012-09-07 08:58:31 +0000
@@ -645,6 +645,9 @@
 
 ** New error type and new function `user-error'.  Doesn't trigger the debugger.
 
++++
+** New utility function `buffer-narrowed-p'.
+
 ** Window changes
 
 *** The functions get-lru-window, get-mru-window and get-largest-window

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-07 08:36:25 +0000
+++ b/lisp/ChangeLog    2012-09-07 08:58:31 +0000
@@ -1,6 +1,13 @@
 2012-09-07  Chong Yidong  <address@hidden>
 
-       * simple.el (count-words--buffer-message): Fix narrowing check.
+       * subr.el (buffer-narrowed-p): New function.
+
+       * ses.el (ses-widen):
+       * simple.el (count-words--buffer-message):
+       * net/browse-url.el (browse-url-of-buffer): Use it
+
+       * simple.el (count-words-region): Don't signal an error if there
+       is a non-nil prefix arg and the mark is not set.
 
        * help.el (describe-key-briefly): Allow the message to be seen
        when invoked from the minibuffer (Bug#7014).

=== modified file 'lisp/emacs-lisp/cl-loaddefs.el'
--- a/lisp/emacs-lisp/cl-loaddefs.el    2012-09-04 17:40:25 +0000
+++ b/lisp/emacs-lisp/cl-loaddefs.el    2012-09-07 08:58:31 +0000
@@ -260,7 +260,7 @@
 ;;;;;;  cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
 ;;;;;;  cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
 ;;;;;;  cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*)
-;;;;;;  "cl-macs" "cl-macs.el" "e09b4be5072a8b52d40af6e073876e76")
+;;;;;;  "cl-macs" "cl-macs.el" "9f9bae5b8ccaf325bd59ba9be2b27c44")
 ;;; Generated autoloads from cl-macs.el
 
 (autoload 'cl--compiler-macro-list* "cl-macs" "\

=== modified file 'lisp/net/browse-url.el'
--- a/lisp/net/browse-url.el    2012-07-11 23:13:41 +0000
+++ b/lisp/net/browse-url.el    2012-09-07 08:58:31 +0000
@@ -743,7 +743,7 @@
     (and buffer (set-buffer buffer))
     (let ((file-name
           ;; Ignore real name if restricted
-          (and (= (- (point-max) (point-min)) (buffer-size))
+          (and (not (buffer-narrowed-p))
                (or buffer-file-name
                    (and (boundp 'dired-directory) dired-directory)))))
       (or file-name

=== modified file 'lisp/ses.el'
--- a/lisp/ses.el       2012-07-22 21:14:12 +0000
+++ b/lisp/ses.el       2012-09-07 08:58:31 +0000
@@ -1270,11 +1270,9 @@
 ;; The data area
 ;;----------------------------------------------------------------------------
 
-(defun ses-narrowed-p () (/= (- (point-max) (point-min)) (buffer-size)))
-
 (defun ses-widen ()
   "Turn off narrowing, to be reenabled at end of command loop."
-  (if (ses-narrowed-p)
+  (if (buffer-narrowed-p)
       (setq ses--deferred-narrow t))
   (widen))
 

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2012-09-07 08:36:25 +0000
+++ b/lisp/simple.el    2012-09-07 08:58:31 +0000
@@ -974,7 +974,9 @@
 
 If called from Lisp, return the number of words between positions
 START and END."
-  (interactive "r\nP")
+  (interactive (if current-prefix-arg
+                  (list nil nil current-prefix-arg)
+                (list (region-beginning) (region-end) nil)))
   (cond ((not (called-interactively-p 'any))
         (count-words start end))
        (arg
@@ -1008,9 +1010,7 @@
 
 (defun count-words--buffer-message ()
   (count-words--message
-   (if (= (- (point-max) (point-min)) (buffer-size))
-       "Buffer"
-     "Narrowed part of buffer")
+   (if (buffer-narrowed-p) "Narrowed part of buffer" "Buffer")
    (point-min) (point-max)))
 
 (defun count-words--message (str start end)

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2012-08-18 05:11:38 +0000
+++ b/lisp/subr.el      2012-09-07 08:58:31 +0000
@@ -2647,6 +2647,10 @@
 
 ;;;; Misc. useful functions.
 
+(defsubst buffer-narrowed-p ()
+  "Return non-nil if the current buffer is narrowed."
+  (/= (- (point-max) (point-min)) (buffer-size)))
+
 (defun find-tag-default ()
   "Determine default tag to search for, based on text at point.
 If there is no plausible default, return nil."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]