370 |
(define-key map "\M-\t" #'flyspell-auto-correct-word))) |
(define-key map "\M-\t" #'flyspell-auto-correct-word))) |
371 |
map)) |
map)) |
372 |
|
|
|
;;;###autoload |
|
|
(defvar flyspell-mode-map (make-sparse-keymap)) |
|
|
|
|
|
;; mouse, keyboard bindings and misc definition |
|
|
(when (or (assoc 'flyspell-mode minor-mode-map-alist) |
|
|
(setq minor-mode-map-alist |
|
|
(cons (cons 'flyspell-mode flyspell-mode-map) |
|
|
minor-mode-map-alist))) |
|
|
(define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word) |
|
|
(define-key flyspell-mode-map [(mouse-2)] |
|
|
(function flyspell-correct-word/local-keymap))) |
|
|
|
|
|
|
|
373 |
;; the name of the overlay property that defines the keymap |
;; the name of the overlay property that defines the keymap |
374 |
(defvar flyspell-overlay-keymap-property-name |
(defvar flyspell-overlay-keymap-property-name 'keymap) |
|
(if (string-match "19.*XEmacs" emacs-version) |
|
|
'keymap |
|
|
'local-map)) |
|
375 |
|
|
376 |
;; dash character machinery |
;; dash character machinery |
377 |
(defvar flyspell-consider-dash-as-word-delimiter-flag nil |
(defvar flyspell-consider-dash-as-word-delimiter-flag nil |
417 |
\\[flyspell-correct-word] (or mouse-2): popup correct words. |
\\[flyspell-correct-word] (or mouse-2): popup correct words. |
418 |
|
|
419 |
Hooks: |
Hooks: |
420 |
flyspell-mode-hook is run after flyspell is entered. |
This runs `flyspell-mode-hook' after flyspell is entered. |
421 |
|
|
422 |
Remark: |
Remark: |
423 |
`flyspell-mode' uses `ispell-mode'. Thus all Ispell options are |
`flyspell-mode' uses `ispell-mode'. Thus all Ispell options are |
429 |
\(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex)))) |
\(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex)))) |
430 |
in your .emacs file. |
in your .emacs file. |
431 |
|
|
432 |
flyspell-region checks all words inside a region. |
\\[flyspell-region] checks all words inside a region. |
433 |
|
\\[flyspell-buffer] checks the whole buffer." |
|
flyspell-buffer checks the whole buffer." |
|
434 |
(interactive "P") |
(interactive "P") |
435 |
(let ((old-flyspell-mode flyspell-mode)) |
(let ((old-flyspell-mode flyspell-mode)) |
436 |
;; Mark the mode as on or off. |
;; Mark the mode as on or off. |
448 |
;* Autoloading */ |
;* Autoloading */ |
449 |
;*---------------------------------------------------------------------*/ |
;*---------------------------------------------------------------------*/ |
450 |
;;;###autoload |
;;;###autoload |
451 |
(if (fboundp 'add-minor-mode) |
(add-minor-mode 'flyspell-mode |
452 |
(add-minor-mode 'flyspell-mode |
'flyspell-mode-line-string |
453 |
'flyspell-mode-line-string |
nil |
454 |
flyspell-mode-map |
nil |
455 |
nil |
'flyspell-mode) |
|
'flyspell-mode) |
|
|
(or (assoc 'flyspell-mode minor-mode-alist) |
|
|
(setq minor-mode-alist |
|
|
(cons '(flyspell-mode flyspell-mode-line-string) |
|
|
minor-mode-alist))) |
|
|
|
|
|
(or (assoc 'flyspell-mode minor-mode-map-alist) |
|
|
(setq minor-mode-map-alist |
|
|
(cons (cons 'flyspell-mode flyspell-mode-map) |
|
|
minor-mode-map-alist)))) |
|
456 |
|
|
457 |
;*---------------------------------------------------------------------*/ |
;*---------------------------------------------------------------------*/ |
458 |
;* flyspell-buffers ... */ |
;* flyspell-buffers ... */ |
505 |
;; we put the `flyspel-deplacement' property on some commands |
;; we put the `flyspel-deplacement' property on some commands |
506 |
(flyspell-deplacement-commands) |
(flyspell-deplacement-commands) |
507 |
;; we bound flyspell action to post-command hook |
;; we bound flyspell action to post-command hook |
|
(make-local-hook 'post-command-hook) |
|
508 |
(add-hook 'post-command-hook (function flyspell-post-command-hook) t t) |
(add-hook 'post-command-hook (function flyspell-post-command-hook) t t) |
509 |
;; we bound flyspell action to pre-command hook |
;; we bound flyspell action to pre-command hook |
|
(make-local-hook 'pre-command-hook) |
|
510 |
(add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t) |
(add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t) |
511 |
;; we bound flyspell action to after-change hook |
;; we bound flyspell action to after-change hook |
512 |
(make-local-variable 'after-change-functions) |
(make-local-variable 'after-change-functions) |
516 |
(let ((mode-predicate (get major-mode 'flyspell-mode-predicate))) |
(let ((mode-predicate (get major-mode 'flyspell-mode-predicate))) |
517 |
(if mode-predicate |
(if mode-predicate |
518 |
(setq flyspell-generic-check-word-p mode-predicate))) |
(setq flyspell-generic-check-word-p mode-predicate))) |
|
;; work around the fact that the `local-map' text-property replaces the |
|
|
;; buffer's local map rather than shadowing it. |
|
|
(set (make-local-variable 'flyspell-mouse-map) |
|
|
(let ((map (copy-keymap flyspell-mouse-map))) |
|
|
(set-keymap-parent map (current-local-map)) |
|
|
map)) |
|
519 |
;; the welcome message |
;; the welcome message |
520 |
(if (and flyspell-issue-welcome-flag (interactive-p)) |
(if (and flyspell-issue-welcome-flag (interactive-p)) |
521 |
(let ((binding (where-is-internal 'flyspell-auto-correct-word |
(let ((binding (where-is-internal 'flyspell-auto-correct-word |
525 |
(format "Welcome to flyspell. Use %s or Mouse-2 to correct words." |
(format "Welcome to flyspell. Use %s or Mouse-2 to correct words." |
526 |
(key-description binding)) |
(key-description binding)) |
527 |
"Welcome to flyspell. Use Mouse-2 to correct words.")))) |
"Welcome to flyspell. Use Mouse-2 to correct words.")))) |
|
|
|
|
;; Use this so that we can still get major mode bindings at a |
|
|
;; misspelled word (unless they're overridden by |
|
|
;; `flyspell-mouse-map'). |
|
|
(set (make-local-variable 'flyspell-local-mouse-map) |
|
|
(let ((map (copy-keymap flyspell-mouse-map))) |
|
|
(if (eq flyspell-emacs 'xemacs) |
|
|
(set-keymap-parents (list (current-local-map))) |
|
|
(set-keymap-parent map (current-local-map))) |
|
|
map)) |
|
528 |
|
|
529 |
;; we end with the flyspell hooks |
;; we end with the flyspell hooks |
530 |
(run-hooks 'flyspell-mode-hook)) |
(run-hooks 'flyspell-mode-hook)) |
1312 |
(defun flyspell-region (beg end) |
(defun flyspell-region (beg end) |
1313 |
"Flyspell text between BEG and END." |
"Flyspell text between BEG and END." |
1314 |
(interactive "r") |
(interactive "r") |
|
(unless (boundp 'flyspell-local-mouse-map) |
|
|
(set (make-local-variable 'flyspell-local-mouse-map) |
|
|
(let ((map (copy-keymap flyspell-mouse-map))) |
|
|
(if (eq flyspell-emacs 'xemacs) |
|
|
(set-keymap-parents (list (current-local-map))) |
|
|
(set-keymap-parent map (current-local-map))) |
|
|
map))) |
|
1315 |
(if (= beg end) |
(if (= beg end) |
1316 |
() |
() |
1317 |
(save-excursion |
(save-excursion |
1443 |
(if flyspell-use-local-map |
(if flyspell-use-local-map |
1444 |
(overlay-put flyspell-overlay |
(overlay-put flyspell-overlay |
1445 |
flyspell-overlay-keymap-property-name |
flyspell-overlay-keymap-property-name |
1446 |
flyspell-local-mouse-map)) |
flyspell-mouse-map)) |
1447 |
flyspell-overlay)) |
flyspell-overlay)) |
1448 |
|
|
1449 |
;*---------------------------------------------------------------------*/ |
;*---------------------------------------------------------------------*/ |