diff options
| author | Richard M. Stallman | 2003-07-07 21:00:26 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-07-07 21:00:26 +0000 |
| commit | 0f7df53513f01086033e91790f558535cde91d7e (patch) | |
| tree | 01e32f44a6282470d4851c9a931dd320f0ee1337 | |
| parent | 12cf32ce47088b2ec29a070d4a2910295675ecdf (diff) | |
| download | emacs-0f7df53513f01086033e91790f558535cde91d7e.tar.gz emacs-0f7df53513f01086033e91790f558535cde91d7e.zip | |
(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.
| -rw-r--r-- | lisp/simple.el | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 1c40c36981a..5d9659cd285 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3150,37 +3150,42 @@ With argument, do this that many times." | |||
| 3150 | (interactive "p") | 3150 | (interactive "p") |
| 3151 | (kill-word (- arg))) | 3151 | (kill-word (- arg))) |
| 3152 | 3152 | ||
| 3153 | (defun current-word (&optional strict) | 3153 | (defun current-word (&optional strict really-word) |
| 3154 | "Return the word point is on (or a nearby word) as a string. | 3154 | "Return the symbol or word that point is on (or a nearby one) as a string. |
| 3155 | The return value includes no text properties. | ||
| 3155 | If optional arg STRICT is non-nil, return nil unless point is within | 3156 | If optional arg STRICT is non-nil, return nil unless point is within |
| 3156 | or adjacent to a word." | 3157 | or adjacent to a symbol or word. |
| 3158 | The function, belying its name, normally finds a symbol. | ||
| 3159 | If optional arg REALLY-WORD is non-nil, it finds just a word." | ||
| 3157 | (save-excursion | 3160 | (save-excursion |
| 3158 | (let ((oldpoint (point)) (start (point)) (end (point))) | 3161 | (let* ((oldpoint (point)) (start (point)) (end (point)) |
| 3159 | (skip-syntax-backward "w_") (setq start (point)) | 3162 | (syntaxes (if really-word "w_" "w")) |
| 3163 | (not-syntaxes (concat "^" syntaxes))) | ||
| 3164 | (skip-syntax-backward syntaxes) (setq start (point)) | ||
| 3160 | (goto-char oldpoint) | 3165 | (goto-char oldpoint) |
| 3161 | (skip-syntax-forward "w_") (setq end (point)) | 3166 | (skip-syntax-forward syntaxes) (setq end (point)) |
| 3162 | (if (and (eq start oldpoint) (eq end oldpoint)) | 3167 | (when (and (eq start oldpoint) (eq end oldpoint) |
| 3163 | ;; Point is neither within nor adjacent to a word. | 3168 | ;; Point is neither within nor adjacent to a word. |
| 3164 | (and (not strict) | 3169 | (not strict)) |
| 3165 | (progn | 3170 | ;; Look for preceding word in same line. |
| 3166 | ;; Look for preceding word in same line. | 3171 | (skip-syntax-backward not-syntaxes |
| 3167 | (skip-syntax-backward "^w_" | 3172 | (save-excursion (beginning-of-line) |
| 3168 | (save-excursion (beginning-of-line) | 3173 | (point))) |
| 3169 | (point))) | 3174 | (if (bolp) |
| 3170 | (if (bolp) | 3175 | ;; No preceding word in same line. |
| 3171 | ;; No preceding word in same line. | 3176 | ;; Look for following word in same line. |
| 3172 | ;; Look for following word in same line. | 3177 | (progn |
| 3173 | (progn | 3178 | (skip-syntax-forward not-syntaxes |
| 3174 | (skip-syntax-forward "^w_" | 3179 | (save-excursion (end-of-line) |
| 3175 | (save-excursion (end-of-line) | 3180 | (point))) |
| 3176 | (point))) | 3181 | (setq start (point)) |
| 3177 | (setq start (point)) | 3182 | (skip-syntax-forward syntaxes) |
| 3178 | (skip-syntax-forward "w_") | 3183 | (setq end (point))) |
| 3179 | (setq end (point))) | 3184 | (setq end (point)) |
| 3180 | (setq end (point)) | 3185 | (skip-syntax-backward syntaxes) |
| 3181 | (skip-syntax-backward "w_") | 3186 | (setq start (point)))) |
| 3182 | (setq start (point))) | 3187 | ;; If we found something nonempty, return it as a string. |
| 3183 | (buffer-substring-no-properties start end))) | 3188 | (unless (= start end) |
| 3184 | (buffer-substring-no-properties start end))))) | 3189 | (buffer-substring-no-properties start end))))) |
| 3185 | 3190 | ||
| 3186 | (defcustom fill-prefix nil | 3191 | (defcustom fill-prefix nil |
| @@ -4481,24 +4486,20 @@ wait this many seconds after Emacs becomes idle before doing an update." | |||
| 4481 | :version "21.4") | 4486 | :version "21.4") |
| 4482 | 4487 | ||
| 4483 | (defvar vis-mode-saved-buffer-invisibility-spec nil | 4488 | (defvar vis-mode-saved-buffer-invisibility-spec nil |
| 4484 | "Saved value of buffer-invisibility-spec when `vis-mode' is on.") | 4489 | "Saved value of `buffer-invisibility-spec' when Visible mode is on.") |
| 4485 | |||
| 4486 | (define-minor-mode vis-mode | ||
| 4487 | "Toggle vis-mode. | ||
| 4488 | With argument ARG turn vis-mode on iff ARG is positive. | ||
| 4489 | 4490 | ||
| 4490 | Enabling vis-mode sets `buffer-invisibility-spec' to nil, after | 4491 | (define-minor-mode visible-mode |
| 4491 | saving the old value in the variable | 4492 | "Toggle Visible mode. |
| 4492 | `vis-mode-saved-buffer-invisibility-spec', making all invisible | 4493 | With argument ARG turn Visible mode on iff ARG is positive. |
| 4493 | text in the buffer visible. | ||
| 4494 | 4494 | ||
| 4495 | Disabling vis-mode restores the saved value of | 4495 | Enabling Visible mode makes all invisible text temporarily visible. |
| 4496 | `buffer-invisibility-spec'." | 4496 | Disabling Visible mode turns off that effect. Visible mode |
| 4497 | works by saving the value of `buffer-invisibility-spec' and setting it to nil." | ||
| 4497 | :lighter " Vis" | 4498 | :lighter " Vis" |
| 4498 | (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec) | 4499 | (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec) |
| 4499 | (setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec) | 4500 | (setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec) |
| 4500 | (kill-local-variable 'vis-mode-saved-buffer-invisibility-spec)) | 4501 | (kill-local-variable 'vis-mode-saved-buffer-invisibility-spec)) |
| 4501 | (when vis-mode | 4502 | (when visible-mode |
| 4502 | (set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec) | 4503 | (set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec) |
| 4503 | buffer-invisibility-spec) | 4504 | buffer-invisibility-spec) |
| 4504 | (setq buffer-invisibility-spec nil))) | 4505 | (setq buffer-invisibility-spec nil))) |