aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2012-09-07 16:58:31 +0800
committerChong Yidong2012-09-07 16:58:31 +0800
commite5c2edf79ba2b75a3572839fcb9de612f93ab630 (patch)
tree97949328a6fba5bf022572d490a3212148f3bed8 /lisp
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.
Diffstat (limited to 'lisp')
-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
6 files changed, 19 insertions, 10 deletions
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."