1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-28 10:56:36 +00:00

(visible-mode): Renamed from vis-mode.

(vis-mode-saved-buffer-invisibility-spec): Doc fix.

(current-word): New arg REALLY-WORD specifies
don't include punctuation chars.
This commit is contained in:
Richard M. Stallman 2003-07-07 21:00:26 +00:00
parent 12cf32ce47
commit 0f7df53513

View File

@ -3150,37 +3150,42 @@ With argument, do this that many times."
(interactive "p") (interactive "p")
(kill-word (- arg))) (kill-word (- arg)))
(defun current-word (&optional strict) (defun current-word (&optional strict really-word)
"Return the word point is on (or a nearby word) as a string. "Return the symbol or word that point is on (or a nearby one) as a string.
The return value includes no text properties.
If optional arg STRICT is non-nil, return nil unless point is within If optional arg STRICT is non-nil, return nil unless point is within
or adjacent to a word." or adjacent to a symbol or word.
The function, belying its name, normally finds a symbol.
If optional arg REALLY-WORD is non-nil, it finds just a word."
(save-excursion (save-excursion
(let ((oldpoint (point)) (start (point)) (end (point))) (let* ((oldpoint (point)) (start (point)) (end (point))
(skip-syntax-backward "w_") (setq start (point)) (syntaxes (if really-word "w_" "w"))
(not-syntaxes (concat "^" syntaxes)))
(skip-syntax-backward syntaxes) (setq start (point))
(goto-char oldpoint) (goto-char oldpoint)
(skip-syntax-forward "w_") (setq end (point)) (skip-syntax-forward syntaxes) (setq end (point))
(if (and (eq start oldpoint) (eq end oldpoint)) (when (and (eq start oldpoint) (eq end oldpoint)
;; Point is neither within nor adjacent to a word. ;; Point is neither within nor adjacent to a word.
(and (not strict) (not strict))
(progn ;; Look for preceding word in same line.
;; Look for preceding word in same line. (skip-syntax-backward not-syntaxes
(skip-syntax-backward "^w_" (save-excursion (beginning-of-line)
(save-excursion (beginning-of-line) (point)))
(point))) (if (bolp)
(if (bolp) ;; No preceding word in same line.
;; No preceding word in same line. ;; Look for following word in same line.
;; Look for following word in same line. (progn
(progn (skip-syntax-forward not-syntaxes
(skip-syntax-forward "^w_" (save-excursion (end-of-line)
(save-excursion (end-of-line) (point)))
(point))) (setq start (point))
(setq start (point)) (skip-syntax-forward syntaxes)
(skip-syntax-forward "w_") (setq end (point)))
(setq end (point))) (setq end (point))
(setq end (point)) (skip-syntax-backward syntaxes)
(skip-syntax-backward "w_") (setq start (point))))
(setq start (point))) ;; If we found something nonempty, return it as a string.
(buffer-substring-no-properties start end))) (unless (= start end)
(buffer-substring-no-properties start end))))) (buffer-substring-no-properties start end)))))
(defcustom fill-prefix nil (defcustom fill-prefix nil
@ -4481,24 +4486,20 @@ wait this many seconds after Emacs becomes idle before doing an update."
:version "21.4") :version "21.4")
(defvar vis-mode-saved-buffer-invisibility-spec nil (defvar vis-mode-saved-buffer-invisibility-spec nil
"Saved value of buffer-invisibility-spec when `vis-mode' is on.") "Saved value of `buffer-invisibility-spec' when Visible mode is on.")
(define-minor-mode vis-mode (define-minor-mode visible-mode
"Toggle vis-mode. "Toggle Visible mode.
With argument ARG turn vis-mode on iff ARG is positive. With argument ARG turn Visible mode on iff ARG is positive.
Enabling vis-mode sets `buffer-invisibility-spec' to nil, after Enabling Visible mode makes all invisible text temporarily visible.
saving the old value in the variable Disabling Visible mode turns off that effect. Visible mode
`vis-mode-saved-buffer-invisibility-spec', making all invisible works by saving the value of `buffer-invisibility-spec' and setting it to nil."
text in the buffer visible.
Disabling vis-mode restores the saved value of
`buffer-invisibility-spec'."
:lighter " Vis" :lighter " Vis"
(when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec) (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec)
(setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec) (setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec)
(kill-local-variable 'vis-mode-saved-buffer-invisibility-spec)) (kill-local-variable 'vis-mode-saved-buffer-invisibility-spec))
(when vis-mode (when visible-mode
(set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec) (set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec)
buffer-invisibility-spec) buffer-invisibility-spec)
(setq buffer-invisibility-spec nil))) (setq buffer-invisibility-spec nil)))