* 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.
2012-09-07 Chong Yidong <cyd@gnu.org>
+ * 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
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
@end example
@end deffn
+@defun buffer-narrowed-p
+This function returns non-@code{nil} if the buffer is narrowed, and
+@code{nil} otherwise.
+@end defun
+
@defspec save-restriction body@dots{}
This special form saves the current bounds of the accessible portion,
evaluates the @var{body} forms, and finally restores the saved bounds,
** 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
2012-09-07 Chong Yidong <cyd@gnu.org>
- * 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).
;;;;;; 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" "\
(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
;; 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))
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
(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)
\f
;;;; 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."