Commit 1d056c0c authored by David Byers's avatar David Byers
Browse files

Improved word completion for commands.

Still not perfect, but better.
parent a8d930ce
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
(defvar lyskom-command-minibuffer-local-completion-map (defvar lyskom-command-minibuffer-local-completion-map
(let ((map (copy-keymap minibuffer-local-completion-map))) (let ((map (copy-keymap minibuffer-local-completion-map)))
(define-key map " " 'lyskom-complete-command-word) (define-key map " " 'lyskom-command-complete-word)
map) map)
"Keymap used for reading LysKOM names.") "Keymap used for reading LysKOM names.")
...@@ -393,27 +393,59 @@ and back of the string." ...@@ -393,27 +393,59 @@ and back of the string."
(substring string (substring string
(next-single-property-change 0 'read-only string)))) (next-single-property-change 0 'read-only string))))
(let ((completion (try-completion string (let ((completion (try-completion string
minibuffer-completion-table minibuffer-completion-table
minibuffer-completion-predicate))) minibuffer-completion-predicate)))
(cond ((null completion) (minibuffer-message " [No match]") nil) (cond ((null completion) (minibuffer-message " [No match]") nil)
((eq completion t) nil) ((eq completion t) nil)
(t (let* ((tmp string)) (t (let* ((tmp string))
(when (and (string-equal (lyskom-unicase completion) (when (and (string-equal (lyskom-unicase completion)
(lyskom-unicase tmp)) (lyskom-unicase tmp))
(not (string-match "\\s-$" completion))) (not (string-match "\\s-$" completion)))
(if (stringp (setq tmp (try-completion (if (stringp (setq tmp (try-completion
(concat tmp " ") (concat tmp " ")
minibuffer-completion-table minibuffer-completion-table
minibuffer-completion-predicate))) minibuffer-completion-predicate)))
(setq completion tmp))) (setq completion tmp)))
(if (string-equal (lyskom-unicase completion) (if (string-equal (lyskom-unicase completion)
(lyskom-unicase string)) (lyskom-unicase string))
(progn (minibuffer-completion-help) nil) (progn (minibuffer-completion-help) nil)
(delete-region (- (point-max) (length string)) (delete-region (- (point-max) (length string))
(point-max)) (point-max))
(insert completion)
t))))))) ;; Now we have the suggested completion
;; Expand what's in the buffer by one real word.
(let* ((count (lyskom-command-complete-count-words string))
(result (lyskom-command-complete-word-truncate
completion count)))
(when (string= result string)
(setq result (lyskom-command-complete-word-truncate
completion (1+ count))))
(insert result))
t)))))))
(defvar lyskom-command-complete-regexp
"\\(([^\)]*)\\s-+\\)*\\S-+\\(\\s-*([^\)]*)\\)*\\(\\s-+\\|\\'\\)")
(defun lyskom-command-complete-word-truncate (completion count)
"Truncate completion COMPLETION to COUNT words."
(let ((start 0))
(while (and (> count 0)
(string-match lyskom-command-complete-regexp completion start))
(setq start (match-end 0)
count (1- count)))
(substring completion 0 start)))
(defun lyskom-command-complete-count-words (string)
"Count number of real words in command name or completion STRING."
(let ((start 0)
(count 0))
(while (string-match lyskom-command-complete-regexp string start)
(setq start (match-end 0)
count (1+ count)))
count))
;;; The code below is an alternative implementation of ;;; The code below is an alternative implementation of
...@@ -421,7 +453,6 @@ and back of the string." ...@@ -421,7 +453,6 @@ and back of the string."
;;; contents of the minibuffer and then calls the regular ;;; contents of the minibuffer and then calls the regular
;;; minibuffer functions. ;;; minibuffer functions.
;;; ;;;
;;;(defvar lyskom-command-complete-regexp "\\(([^)]*)\\s-*\\)*\\S-+\\(\\s-*([^)]*)\\)*\\(\\s-+\\|\\'\\)")
;;; ;;;
;;;(defun lyskom-command-complete-word-count-words (string) ;;;(defun lyskom-command-complete-word-count-words (string)
;;; (let ((count 0) ;;; (let ((count 0)
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
Lysator, see <URL:http://www.lysator.liu.se/>. For more information Lysator, see <URL:http://www.lysator.liu.se/>. For more information
on LysKOM, see <URL:http://www.lysator.liu.se/lyskom/>. on LysKOM, see <URL:http://www.lysator.liu.se/lyskom/>.
The latest version of the Emacs Lisp client for LysKOM is available The latest version of the Emacs Lisp client for LysKOM is available
from <URL:ftp://ftp.lysator.liu.se/pub/lyskom/elisp-client/>. from <URL:http://www.lysator.liu.se/lyskom/klienter/emacslisp/>.
LysKOM is free software; you can redistribute it and/or modify it LysKOM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
...@@ -38,22 +38,18 @@ ...@@ -38,22 +38,18 @@
1. REQUIREMENTS 1. REQUIREMENTS
You need an Emacs. The client appears to work with the following You need an Emacs. The client appears to work completely with the
versions of Emacs: following versions of Emacs:
* XEmacs version 20.4, 21.1 and newer * XEmacs version 21.4 and newer
* Gnu Emacs version 19.34 [1] * Gnu Emacs version 20.7 and newer
* Gnu Emacs version 20.7 and newer [2]
[1] You'll have to replace the included custom package, and if you The client may work with earlier versions of Emacs and XEmacs. To
use Gnus, you may have to update that as well. compile in Emacs 19.34 you will have to replace the included
custom package, and if you use Gnus you may have to update that as
well (see below).
[2] It should be possible to run the client in Gnu Emacs 20.2 and There are some requirements on supplemental elisp packages:
later, but you may experience some additional problems. Column
alignment is known to fail in version 20.2.
There are also some requirements on supplemental elisp packages:
* custom * custom
...@@ -75,14 +71,16 @@ ...@@ -75,14 +71,16 @@
package, it's time to upgrade. The latest version of Gnus is package, it's time to upgrade. The latest version of Gnus is
available from <URL:http://www.gnus.org/>. available from <URL:http://www.gnus.org/>.
* You must NOT HAVE macedit.el * You should NOT HAVE macedit.el
Make sure you do not have a file called macedit.el early in your Make sure you do not have a file called macedit.el early in your
load path. This file redefines a function that the client relies load path. This file redefines a function that the client relies
heavily on. The redefinition is buggy. You can recognize this heavily on. The redefinition is buggy. The client will attempt
problem if your Emacs says something like this: "Key sequence < to detect this situation and fix it by loading edmacro. If you
m o u s e - 2 > uses invalid prefix characters" when you load or have macedit but not edmacro, you will experience problems. You
compile the elisp client. can recognize this situation if your Emacs says something like
this: "Key sequence < m o u s e - 2 > uses invalid prefix
characters" when you load or compile the elisp client.
* w3 4.0 or later (optional) * w3 4.0 or later (optional)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
1. Set up autoloading by adding the following line to your .emacs 1. Set up autoloading by adding the following line to your .emacs
or any other file that Emacs loads at startup (such as or any other file that Emacs loads at startup (such as
site-start.el or default.el): ~/.emacs, site-start.el or default.el):
(autoload 'lyskom "lyskom" "Start LysKOM" t) (autoload 'lyskom "lyskom" "Start LysKOM" t)
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
your site init file (default.el or site-start.el). For example, your site init file (default.el or site-start.el). For example,
if you are running a server on kom.domain.org, you might want if you are running a server on kom.domain.org, you might want
to say something like this in your init file: to say something like this in your init file:
(defvar kom-server-aliases (defvar kom-server-aliases
'(("kom.domain.org . "DomainKOM") '(("kom.domain.org . "DomainKOM")
("kom.lysator.liu.se . "LysKOM"))) ("kom.lysator.liu.se . "LysKOM")))
The first server listed in kom-server-aliases will be the The first server listed in kom-server-aliases will be the
default server for new users. default server for new users.
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
Before reporting a bug, please check that it is not one of the Before reporting a bug, please check that it is not one of the
known issues below. Please report bugs by posting them to the known issues below. Please report bugs by posting them to the
bugzilla at http://bugzilla.lysator.liu.se/. You can also e-mail bugzilla at http://bugzilla.lysator.liu.se/. You can also e-mail
bug reports to bug-lyskom@lysator.liu.se. bug reports to bug-lyskom@lysator.liu.se if you are unable or
unwilling to use bugzilla.
To evaluate your bug report we need the following information: To evaluate your bug report we need the following information:
...@@ -58,8 +59,40 @@ ...@@ -58,8 +59,40 @@
4. Known issues 4. Known issues
Issue: I see \201 before Swedish characters in the string showing Issue: Cannot enter conference names containing international
what some other user is doing (e.g. L\201äser). characters.
Reason: You may be using a different character coding from the
server, and conversion to the server's coding is not
working. For example, many versions of Emacs are unable to
convert from iso-8859-15 (latin-9) to iso-8859-1 (latin-1)
even though most characters are the same.
Switching to the character coding used by the server by
using set-language-environment (probably to Latin-1) will
fix this problem. If you are unwilling to do this, you can
try loading the ucs-tables Emacs library (a version of this
file is available from <URL:http://www.lysator.liu.se/
lyskom/klienter/emacslisp/>).
Issue: Problems displaying many normal-looking texts.
Reason: Recent versions of some Linux distributions encourage users
to use the latin9 language environment, which results in
texts coded using iso-8859-15. If you do not have fonts
suitable for displaying this character coding you may
experience some problems with such texts. To fix this
problem, install fonts suitable for displaying iso-8859-15
characters. You may also be able to fix it by loading
either the ucs-tables or the latin-unity Emacs library
(a version of ucs-tables is available from <URL:http://www.
lysator.liu.se/lyskom/klienter/emacslisp/> and latin-unity
is available from the XEmacs package system).
Issue: I see \201 before international characters in the string
showing what some other user is doing (e.g. L\201äser).
Reason: The user is probably using an old version of the client in Reason: The user is probably using an old version of the client in
a new version of Emacs. You can confirm this by using the a new version of Emacs. You can confirm this by using the
...@@ -87,7 +120,8 @@ ...@@ -87,7 +120,8 @@
Reason: If Swedish characters show up as blanks your font probably Reason: If Swedish characters show up as blanks your font probably
does not support them. If they show up as question marks or does not support them. If they show up as question marks or
numbers your language environment does not support them. numbers your language environment does not support them or
you are lacking the fonts to display them.
Make sure that your language environment is set correctly Make sure that your language environment is set correctly
with set-language-environment. Just setting the environment with set-language-environment. Just setting the environment
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
give the path to the lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.el contained give the path to the lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.el contained
in the archive in which you found this README file. in the archive in which you found this README file.
You may see some warnings when you compile. Most of these can You may see some warnings when you compile. These can usually be
be ignored. When compilation is done you should have a new file ignored. When compilation is done you should have a new file named
named lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.elc located in the same lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.elc located in the same
directory as lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.el. directory as lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.el.
2. Copy lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.elc to where you want to 2. Copy lyskom-@@FLAVOUR@@-@@CLIENTVERSION@@.elc to where you want to
...@@ -21,9 +21,4 @@ ...@@ -21,9 +21,4 @@
Check the value of load-path (C-h v l o a d - p a t h RET) to Check the value of load-path (C-h v l o a d - p a t h RET) to
see possible locations. see possible locations.
More thorough instructions (written in Swedish) for installation
on Windows is available here:
http://www.lysator.liu.se/lyskom/klienter/emacslisp/win2k.html
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment