[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 126/352: Parannetaan virhetilanteiden tarkistusta ja virheilmoitu
From: |
Stefan Monnier |
Subject: |
[elpa] 126/352: Parannetaan virhetilanteiden tarkistusta ja virheilmoituksia |
Date: |
Mon, 07 Jul 2014 14:03:10 +0000 |
monnier pushed a commit to branch master
in repository elpa.
commit 726623b96ffac871d3d46d5e0611582ed0765380
Author: Teemu Likonen <address@hidden>
Date: Sat Jul 25 11:08:39 2009 +0000
Parannetaan virhetilanteiden tarkistusta ja virheilmoituksia
---
wcheck-mode.el | 129 +++++++++++++++++++++++++++++---------------------------
1 files changed, 67 insertions(+), 62 deletions(-)
diff --git a/wcheck-mode.el b/wcheck-mode.el
index 991c74e..deea306 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -303,8 +303,7 @@ interactively) then change the global default language."
;; off the mode.
(when wcheck-mode
(wcheck-mode -1))
- (message "Language \"%s\": program \"%s\" is not executable"
- language program))
+ (wcheck-error-program-not-executable language program))
;; If the mode is currently turned on we request an update
(wcheck-mode
@@ -354,18 +353,22 @@ information on how to configure Wcheck mode. Interactive
command
(message "Can't use `wcheck-mode' in a minibuffer")
(setq wcheck-mode nil))
- ((not (wcheck-language-valid-p wcheck-language))
+ ((not (wcheck-language-exists-p wcheck-language))
;; Not a valid language.
(wcheck-mode -1)
- (message "Language \"%s\" is not valid" wcheck-language))
+ (message "Language %sdoes not exist; check the configuration"
+ (if (and (stringp wcheck-language)
+ (> (length wcheck-language) 0))
+ (format "\"%s\" " wcheck-language)
+ "")))
((not (wcheck-program-executable-p
(wcheck-query-language-data wcheck-language 'program)))
;; The program does not exist or is not executable.
(wcheck-mode -1)
- (message "Language \"%s\": program \"%s\" is not executable"
- wcheck-language
- (wcheck-query-language-data wcheck-language 'program)))
+ (wcheck-error-program-not-executable
+ wcheck-language
+ (wcheck-query-language-data wcheck-language 'program)))
(t
;; We are ready to really turn on the mode.
@@ -447,32 +450,25 @@ in buffers."
(setq wcheck-received-words nil
wcheck-buffer-window-areas nil)
- (if (not (wcheck-language-valid-p
- (wcheck-get-data :buffer buffer :language)))
- (progn
- (wcheck-mode -1)
- (message "Language \"%s\" is not valid"
- (wcheck-get-data :buffer buffer :language)))
-
- ;; Walk through all windows which belong to this buffer.
- (let (area-alist words)
- (walk-windows #'(lambda (window)
- (when (eq buffer (window-buffer window))
- ;; Store the visible buffer area.
- (push (cons (window-start window)
- (window-end window t))
- area-alist)))
- 'nomb t)
-
- ;; Combine overlapping buffer areas and read words from all
- ;; areas.
- (setq wcheck-buffer-window-areas (wcheck-combine-overlapping-areas
- area-alist))
- (dolist (area wcheck-buffer-window-areas)
- (setq words (append words (wcheck-read-words
- buffer (car area) (cdr area)))))
- ;; Send words to external process.
- (wcheck-send-words buffer words)))))
+ ;; Walk through all windows which belong to this buffer.
+ (let (area-alist words)
+ (walk-windows #'(lambda (window)
+ (when (eq buffer (window-buffer window))
+ ;; Store the visible buffer area.
+ (push (cons (window-start window)
+ (window-end window t))
+ area-alist)))
+ 'nomb t)
+
+ ;; Combine overlapping buffer areas and read words from all
+ ;; areas.
+ (setq wcheck-buffer-window-areas (wcheck-combine-overlapping-areas
+ area-alist))
+ (dolist (area wcheck-buffer-window-areas)
+ (setq words (append words (wcheck-read-words
+ buffer (car area) (cdr area)))))
+ ;; Send words to external process.
+ (wcheck-send-words buffer words))))
;; Start a timer which will mark text in buffers/windows.
(run-with-idle-timer (+ wcheck-timer-idle
@@ -497,24 +493,20 @@ call. The delay between consecutive calls is defined in
variable
`wcheck-timer-idle'."
(dolist (buffer wcheck-timer-paint-requested)
- (with-current-buffer buffer
- (wcheck-remove-overlays)
-
- ;; We are about to mark text in this buffer so remove the buffer
- ;; from the request list.
- (wcheck-timer-remove-paint-request buffer)
-
- ;; Walk through the visible text areas and mark text based on the
- ;; word list returned by an external process.
- (cond ((not wcheck-mode) nil)
- ((not (wcheck-process-running-p buffer))
- (wcheck-mode -1)
- (message "Process is not running for buffer \"%s\""
- (buffer-name buffer)))
- (t
- (dolist (area wcheck-buffer-window-areas)
- (wcheck-paint-words buffer (car area) (cdr area)
- wcheck-received-words))))))
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (wcheck-remove-overlays)
+
+ ;; We are about to mark text in this buffer so remove the buffer
+ ;; from the request list.
+ (wcheck-timer-remove-paint-request buffer)
+
+ ;; Walk through the visible text areas and mark text based on
+ ;; the word list returned by an external process.
+ (when wcheck-mode
+ (dolist (area wcheck-buffer-window-areas)
+ (wcheck-paint-words buffer (car area) (cdr area)
+ wcheck-received-words))))))
;; If REPEAT is positive integer call this function again after
;; waiting wcheck-timer-idle. Pass REPEAT minus one as the argument.
@@ -531,9 +523,18 @@ call. The delay between consecutive calls is defined in
variable
(let ((buffer (wcheck-get-data :process process :buffer)))
(when (buffer-live-p buffer)
(with-current-buffer buffer
- (setq wcheck-received-words
- (append wcheck-received-words (split-string string "\n+" t)))
- (wcheck-timer-add-paint-request buffer)))))
+
+ ;; If process is running proceed to collect and paint the words.
+ (if (eq 'run (process-status process))
+ (progn (setq wcheck-received-words
+ (append wcheck-received-words
+ (split-string string "\n+" t)))
+ (wcheck-timer-add-paint-request buffer))
+
+ ;; It's not running. Turn off the mode.
+ (wcheck-mode -1)
+ (message "Process is not running for buffer \"%s\""
+ (buffer-name buffer)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -677,11 +678,6 @@ operation was unsuccessful."
proc))))
-(defun wcheck-process-running-p (buffer)
- "Return t if the process for BUFFER is running."
- (eq 'run (process-status (wcheck-get-data :buffer buffer :process))))
-
-
(defun wcheck-update-buffer-data (buffer language)
"Update process and language data for BUFFER.
Calling this function is the primary way to maintain the language
@@ -873,10 +869,11 @@ defined in `wcheck-language-data-defaults'."
value))))
-(defun wcheck-language-valid-p (language)
- "Return t if LANGUAGE exists and has configured external program."
+(defun wcheck-language-exists-p (language)
+ "Return t if LANGUAGE exists in `wcheck-language-data'."
(and (member language (mapcar #'car wcheck-language-data))
- (stringp (wcheck-query-language-data language 'program))
+ (stringp language)
+ (> (length language) 0)
t))
@@ -888,6 +885,14 @@ defined in `wcheck-language-data-defaults'."
t))
+(defun wcheck-error-program-not-executable (language program)
+ (if (and (stringp program)
+ (> (length program) 0))
+ (message "Language \"%s\": program \"%s\" is not executable"
+ language program)
+ (message "Language \"%s\": program is not configured" language)))
+
+
(defun wcheck-current-idle-time-seconds ()
"Return current idle time in seconds.
The returned value is a floating point number."
- [elpa] 270/352: Revert "Clarify that OPERATION-MODE can be also be nil", (continued)
- [elpa] 270/352: Revert "Clarify that OPERATION-MODE can be also be nil", Stefan Monnier, 2014/07/07
- [elpa] 285/352: Make "syntax" and "case-fold" effective with "program" function, Stefan Monnier, 2014/07/07
- [elpa] 193/352: Vaihdetaan muuttujan nimi paremmin tarkoitusta kuvaamvaksi, Stefan Monnier, 2014/07/07
- [elpa] 291/352: Version 2011.07.04, Stefan Monnier, 2014/07/07
- [elpa] 172/352: Lisätään autoload-komento alun asennusohjeisiin (-spelling-suggestions), Stefan Monnier, 2014/07/07
- [elpa] 348/352: Enchant must be restarted after calling enchant-add-to-dictionary, Stefan Monnier, 2014/07/07
- [elpa] 338/352: Silence byte-compiler warning about SHOW-ENTRY function, Stefan Monnier, 2014/07/07
- [elpa] 297/352: Remove "A" from the README file's subtitle, Stefan Monnier, 2014/07/07
- [elpa] 304/352: A minor document fix, Stefan Monnier, 2014/07/07
- [elpa] 211/352: Hiotaan vielä oikolukuehdotusten ohjelmavirheenkäsittelyä, Stefan Monnier, 2014/07/07
- [elpa] 126/352: Parannetaan virhetilanteiden tarkistusta ja virheilmoituksia,
Stefan Monnier <=
- [elpa] 298/352: Update link to README.org, Stefan Monnier, 2014/07/07
- [elpa] 350/352: Use PUSH instead of ADD-TO-LIST, Stefan Monnier, 2014/07/07
- [elpa] 213/352: Poistetaan ylimääräinen parametri signal-funktiolta, Stefan Monnier, 2014/07/07
- [elpa] 128/352: Siirretään funktion wcheck-receive-words paikkaa, Stefan Monnier, 2014/07/07
- [elpa] 127/352: Siirretään ylläpitotehtäviä funktioon, jossa niitä muutenkin tehdään, Stefan Monnier, 2014/07/07
- [elpa] 196/352: Uusi macro: wcheck-with-language-data, Stefan Monnier, 2014/07/07
- [elpa] 330/352: Add hyperlinks to Emacs, Flyspell and Speck mode, Stefan Monnier, 2014/07/07
- [elpa] 300/352: Simplify the customize code of wcheck-language-data, Stefan Monnier, 2014/07/07
- [elpa] 328/352: Add another <>'s around the email address, Stefan Monnier, 2014/07/07
- [elpa] 146/352: Käytetään #'-lukijamakroa funktion edessä, Stefan Monnier, 2014/07/07