monnier pushed a commit to branch master
in repository elpa.
commit b11db64f352d48e12338b21b630b1a89f9fefe80
Author: Teemu Likonen <[email protected]>
Date: Sun Jan 9 12:28:29 2011 +0000
Hiotaan oikolukuehdotusten valikkoa
Oikolukuehdotusten tulosteesta poistetaan mahdolliset ohjausmerkit,
kuten rivinvaihdot ja muut näkymättömät merkit. Myös välilyönnit
poistetaan alusta ja lopusta. Tämä tekee ehdotusvalikosta siistimmän,
mikäli se sisältää tällaisia epätavallisia merkkejä. Emacs-puskuriin
korvattavaan merkkijonoon ei tietenkään kosketa.
---
wcheck-mode.el | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/wcheck-mode.el b/wcheck-mode.el
index 035ed07..0743aca 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -1585,6 +1585,15 @@ there aren't any)."
(signal 'wcheck-not-a-list-of-strings-error nil)))))))
+(defun wcheck-clean-string (string)
+ (if (equal string "")
+ "[Empty string]"
+ (setq string (replace-regexp-in-string "[^[:print:]]+" "" string))
+ (if (not (string-match "[^[:space:]]" string))
+ "[Space or control chars]"
+ (replace-regexp-in-string "\\(?:\\` +\\| +\\'\\)" "" string))))
+
+
(defun wcheck-choose-suggestion-popup (suggestions event)
"Create a pop-up menu to choose a substitute suggestion.
SUGGESTIONS is a list of strings. EVENT is the mouse event that
@@ -1593,9 +1602,7 @@ choice (a string) or nil."
(let ((menu (list "Choose a substitute"
(cons "" (if suggestions
(mapcar #'(lambda (item)
- (cons (if (> (length item) 0)
- item
- "[Empty string]")
+ (cons (wcheck-clean-string item)
item))
suggestions)
(list "[No suggestions]"))))))
@@ -1628,11 +1635,7 @@ or nil."
suggestions (cdr suggestions)
string (concat (propertize (format "%c)" (car chars))
'face 'bold)
- " "
- (if (> (length sug) 0)
- sug
- "[Empty string]")
- " ")
+ " " (wcheck-clean-string sug) " ")
alist (cons (cons (car chars) sug) alist)
chars (cdr chars))
(insert string)