/[emacs]/emacs/lisp/simple.el
ViewVC logotype

Diff of /emacs/lisp/simple.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.613 by teirllm, Tue Jul 1 22:15:33 2003 UTC revision 1.614 by rms, Mon Jul 7 21:00:26 2003 UTC
# Line 3150  With argument, do this that many times." Line 3150  With argument, do this that many times."
3150    (interactive "p")    (interactive "p")
3151    (kill-word (- arg)))    (kill-word (- arg)))
3152    
3153  (defun current-word (&optional strict)  (defun current-word (&optional strict really-word)
3154    "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.
3155    The return value includes no text properties.
3156  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
3157  or adjacent to a word."  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."
3160    (save-excursion    (save-excursion
3161      (let ((oldpoint (point)) (start (point)) (end (point)))      (let* ((oldpoint (point)) (start (point)) (end (point))
3162        (skip-syntax-backward "w_") (setq start (point))             (syntaxes (if really-word "w_" "w"))
3163               (not-syntaxes (concat "^" syntaxes)))
3164          (skip-syntax-backward syntaxes) (setq start (point))
3165        (goto-char oldpoint)        (goto-char oldpoint)
3166        (skip-syntax-forward "w_") (setq end (point))        (skip-syntax-forward syntaxes) (setq end (point))
3167        (if (and (eq start oldpoint) (eq end oldpoint))        (when (and (eq start oldpoint) (eq end oldpoint)
3168            ;; Point is neither within nor adjacent to a word.                   ;; Point is neither within nor adjacent to a word.
3169            (and (not strict)                   (not strict))
3170                 (progn          ;; Look for preceding word in same line.
3171                   ;; Look for preceding word in same line.          (skip-syntax-backward not-syntaxes
3172                   (skip-syntax-backward "^w_"                                (save-excursion (beginning-of-line)
3173                                         (save-excursion (beginning-of-line)                                                (point)))
3174                                                         (point)))          (if (bolp)
3175                   (if (bolp)              ;; No preceding word in same line.
3176                       ;; No preceding word in same line.              ;; Look for following word in same line.
3177                       ;; Look for following word in same line.              (progn
3178                       (progn                (skip-syntax-forward not-syntaxes
3179                         (skip-syntax-forward "^w_"                                     (save-excursion (end-of-line)
3180                                              (save-excursion (end-of-line)                                                     (point)))
3181                                                              (point)))                (setq start (point))
3182                         (setq start (point))                (skip-syntax-forward syntaxes)
3183                         (skip-syntax-forward "w_")                (setq end (point)))
3184                         (setq end (point)))            (setq end (point))
3185                     (setq end (point))            (skip-syntax-backward syntaxes)
3186                     (skip-syntax-backward "w_")            (setq start (point))))
3187                     (setq start (point)))        ;; If we found something nonempty, return it as a string.
3188                   (buffer-substring-no-properties start end)))        (unless (= start end)
3189          (buffer-substring-no-properties start end)))))          (buffer-substring-no-properties start end)))))
3190    
3191  (defcustom fill-prefix nil  (defcustom fill-prefix nil
# Line 4481  wait this many seconds after Emacs becom Line 4486  wait this many seconds after Emacs becom
4486    :version "21.4")    :version "21.4")
4487    
4488  (defvar vis-mode-saved-buffer-invisibility-spec nil  (defvar vis-mode-saved-buffer-invisibility-spec nil
4489    "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  
   "Toggle vis-mode.  
 With argument ARG turn vis-mode on iff ARG is positive.  
   
 Enabling vis-mode sets `buffer-invisibility-spec' to nil, after  
 saving the old value in the variable  
 `vis-mode-saved-buffer-invisibility-spec', making all invisible  
 text in the buffer visible.  
4490    
4491  Disabling vis-mode restores the saved value of  (define-minor-mode visible-mode
4492  `buffer-invisibility-spec'."    "Toggle Visible mode.
4493    With argument ARG turn Visible mode on iff ARG is positive.
4494    
4495    Enabling Visible mode makes all invisible text temporarily visible.
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."
4498    :lighter " Vis"    :lighter " Vis"
4499    (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec)    (when (local-variable-p 'vis-mode-saved-buffer-invisibility-spec)
4500      (setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec)      (setq buffer-invisibility-spec vis-mode-saved-buffer-invisibility-spec)
4501      (kill-local-variable 'vis-mode-saved-buffer-invisibility-spec))      (kill-local-variable 'vis-mode-saved-buffer-invisibility-spec))
4502    (when vis-mode    (when visible-mode
4503      (set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec)      (set (make-local-variable 'vis-mode-saved-buffer-invisibility-spec)
4504           buffer-invisibility-spec)           buffer-invisibility-spec)
4505      (setq buffer-invisibility-spec nil)))      (setq buffer-invisibility-spec nil)))

Legend:
Removed from v.1.613  
changed lines
  Added in v.1.614

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26