aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-09-07 16:58:31 +0800
committerChong Yidong2012-09-07 16:58:31 +0800
commite5c2edf79ba2b75a3572839fcb9de612f93ab630 (patch)
tree97949328a6fba5bf022572d490a3212148f3bed8
parenteddb36a7d58b99e43deadcc808347008fe8a8627 (diff)
downloademacs-e5c2edf79ba2b75a3572839fcb9de612f93ab630.tar.gz
emacs-e5c2edf79ba2b75a3572839fcb9de612f93ab630.zip
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.
-rw-r--r--doc/lispref/ChangeLog2
-rw-r--r--doc/lispref/positions.texi29
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el2
-rw-r--r--lisp/net/browse-url.el2
-rw-r--r--lisp/ses.el4
-rw-r--r--lisp/simple.el8
-rw-r--r--lisp/subr.el4
9 files changed, 41 insertions, 22 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index bd21100dd4c..179f81990a7 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,7 @@
12012-09-07 Chong Yidong <cyd@gnu.org> 12012-09-07 Chong Yidong <cyd@gnu.org>
2 2
3 * positions.texi (Narrowing): Document buffer-narrowed-p.
4
3 * markers.texi (Moving Markers): Add xref to Point (Bug#7151). 5 * markers.texi (Moving Markers): Add xref to Point (Bug#7151).
4 6
5 * syntax.texi (Low-Level Parsing): Add xref to Parser State 7 * syntax.texi (Low-Level Parsing): Add xref to Parser State
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index a0c65319850..c4576e6456d 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -874,18 +874,18 @@ commands to a limited range of characters in a buffer. The text that
874remains addressable is called the @dfn{accessible portion} of the 874remains addressable is called the @dfn{accessible portion} of the
875buffer. 875buffer.
876 876
877 Narrowing is specified with two buffer positions which become the 877 Narrowing is specified with two buffer positions, which become the
878beginning and end of the accessible portion. For most editing commands 878beginning and end of the accessible portion. For most editing
879and most Emacs primitives, these positions replace the values of the 879commands and primitives, these positions replace the values of the
880beginning and end of the buffer. While narrowing is in effect, no text 880beginning and end of the buffer. While narrowing is in effect, no
881outside the accessible portion is displayed, and point cannot move 881text outside the accessible portion is displayed, and point cannot
882outside the accessible portion. 882move outside the accessible portion. Note that narrowing does not
883 883alter actual buffer positions (@pxref{Point}); it only determines
884 Values such as positions or line numbers, which usually count from the 884which positions are considered the accessible portion of the buffer.
885beginning of the buffer, do so despite narrowing, but the functions 885Most functions refuse to operate on text that is outside the
886which use them refuse to operate on text that is inaccessible. 886accessible portion.
887 887
888 The commands for saving buffers are unaffected by narrowing; they save 888 Commands for saving buffers are unaffected by narrowing; they save
889the entire buffer regardless of any narrowing. 889the entire buffer regardless of any narrowing.
890 890
891 If you need to display in a single buffer several very different 891 If you need to display in a single buffer several very different
@@ -924,6 +924,11 @@ It is equivalent to the following expression:
924@end example 924@end example
925@end deffn 925@end deffn
926 926
927@defun buffer-narrowed-p
928This function returns non-@code{nil} if the buffer is narrowed, and
929@code{nil} otherwise.
930@end defun
931
927@defspec save-restriction body@dots{} 932@defspec save-restriction body@dots{}
928This special form saves the current bounds of the accessible portion, 933This special form saves the current bounds of the accessible portion,
929evaluates the @var{body} forms, and finally restores the saved bounds, 934evaluates the @var{body} forms, and finally restores the saved bounds,
diff --git a/etc/NEWS b/etc/NEWS
index bc1c49fe946..b85d64f83a3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -645,6 +645,9 @@ The interpretation of the DECLS is determined by `defun-declarations-alist'.
645 645
646** New error type and new function `user-error'. Doesn't trigger the debugger. 646** New error type and new function `user-error'. Doesn't trigger the debugger.
647 647
648+++
649** New utility function `buffer-narrowed-p'.
650
648** Window changes 651** Window changes
649 652
650*** The functions get-lru-window, get-mru-window and get-largest-window 653*** The functions get-lru-window, get-mru-window and get-largest-window
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 33e641b5fc1..7aae8fd7854 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,13 @@
12012-09-07 Chong Yidong <cyd@gnu.org> 12012-09-07 Chong Yidong <cyd@gnu.org>
2 2
3 * simple.el (count-words--buffer-message): Fix narrowing check. 3 * subr.el (buffer-narrowed-p): New function.
4
5 * ses.el (ses-widen):
6 * simple.el (count-words--buffer-message):
7 * net/browse-url.el (browse-url-of-buffer): Use it
8
9 * simple.el (count-words-region): Don't signal an error if there
10 is a non-nil prefix arg and the mark is not set.
4 11
5 * help.el (describe-key-briefly): Allow the message to be seen 12 * help.el (describe-key-briefly): Allow the message to be seen
6 when invoked from the minibuffer (Bug#7014). 13 when invoked from the minibuffer (Bug#7014).
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index 7d70d22c9cd..a59beaeb7ac 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -260,7 +260,7 @@ Remove from SYMBOL's plist the property PROPNAME and its value.
260;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when 260;;;;;; cl-typecase cl-ecase cl-case cl-load-time-value cl-eval-when
261;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp 261;;;;;; cl-destructuring-bind cl-function cl-defmacro cl-defun cl-gentemp
262;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*) 262;;;;;; cl-gensym cl--compiler-macro-cXXr cl--compiler-macro-list*)
263;;;;;; "cl-macs" "cl-macs.el" "e09b4be5072a8b52d40af6e073876e76") 263;;;;;; "cl-macs" "cl-macs.el" "9f9bae5b8ccaf325bd59ba9be2b27c44")
264;;; Generated autoloads from cl-macs.el 264;;; Generated autoloads from cl-macs.el
265 265
266(autoload 'cl--compiler-macro-list* "cl-macs" "\ 266(autoload 'cl--compiler-macro-list* "cl-macs" "\
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 20d71215926..d1d33bfe566 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -743,7 +743,7 @@ narrowed."
743 (and buffer (set-buffer buffer)) 743 (and buffer (set-buffer buffer))
744 (let ((file-name 744 (let ((file-name
745 ;; Ignore real name if restricted 745 ;; Ignore real name if restricted
746 (and (= (- (point-max) (point-min)) (buffer-size)) 746 (and (not (buffer-narrowed-p))
747 (or buffer-file-name 747 (or buffer-file-name
748 (and (boundp 'dired-directory) dired-directory))))) 748 (and (boundp 'dired-directory) dired-directory)))))
749 (or file-name 749 (or file-name
diff --git a/lisp/ses.el b/lisp/ses.el
index 8add16a6996..7cdac74e310 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -1270,11 +1270,9 @@ when the width of cell (ROW,COL) has changed."
1270;; The data area 1270;; The data area
1271;;---------------------------------------------------------------------------- 1271;;----------------------------------------------------------------------------
1272 1272
1273(defun ses-narrowed-p () (/= (- (point-max) (point-min)) (buffer-size)))
1274
1275(defun ses-widen () 1273(defun ses-widen ()
1276 "Turn off narrowing, to be reenabled at end of command loop." 1274 "Turn off narrowing, to be reenabled at end of command loop."
1277 (if (ses-narrowed-p) 1275 (if (buffer-narrowed-p)
1278 (setq ses--deferred-narrow t)) 1276 (setq ses--deferred-narrow t))
1279 (widen)) 1277 (widen))
1280 1278
diff --git a/lisp/simple.el b/lisp/simple.el
index ca73ba1b03a..d87ae3c5c15 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -974,7 +974,9 @@ rather than the region.
974 974
975If called from Lisp, return the number of words between positions 975If called from Lisp, return the number of words between positions
976START and END." 976START and END."
977 (interactive "r\nP") 977 (interactive (if current-prefix-arg
978 (list nil nil current-prefix-arg)
979 (list (region-beginning) (region-end) nil)))
978 (cond ((not (called-interactively-p 'any)) 980 (cond ((not (called-interactively-p 'any))
979 (count-words start end)) 981 (count-words start end))
980 (arg 982 (arg
@@ -1008,9 +1010,7 @@ END, without printing any message."
1008 1010
1009(defun count-words--buffer-message () 1011(defun count-words--buffer-message ()
1010 (count-words--message 1012 (count-words--message
1011 (if (= (- (point-max) (point-min)) (buffer-size)) 1013 (if (buffer-narrowed-p) "Narrowed part of buffer" "Buffer")
1012 "Buffer"
1013 "Narrowed part of buffer")
1014 (point-min) (point-max))) 1014 (point-min) (point-max)))
1015 1015
1016(defun count-words--message (str start end) 1016(defun count-words--message (str start end)
diff --git a/lisp/subr.el b/lisp/subr.el
index 74afd59f8d5..621622e70eb 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2647,6 +2647,10 @@ directory if it does not exist."
2647 2647
2648;;;; Misc. useful functions. 2648;;;; Misc. useful functions.
2649 2649
2650(defsubst buffer-narrowed-p ()
2651 "Return non-nil if the current buffer is narrowed."
2652 (/= (- (point-max) (point-min)) (buffer-size)))
2653
2650(defun find-tag-default () 2654(defun find-tag-default ()
2651 "Determine default tag to search for, based on text at point. 2655 "Determine default tag to search for, based on text at point.
2652If there is no plausible default, return nil." 2656If there is no plausible default, return nil."