Commit 881d74e3 authored by David Byers's avatar David Byers
Browse files

Cleanup of command completion code.

parent 60e22571
2000-09-02 David Byers <davby@sen2.ida.liu.se>
* completing-read.el (lyskom-completing-strip-name): Added
DONT-STRIP-SPACES argument.
2000-09-02 David Byers <davby@ida.liu.se>
* command.el (lyskom-command-match-string-regexp): New function.
(lyskom-completing-strip-command): New function.
(lyskom-complete-command): Record exact matches when iterating
through alternatives. Fix lyskom-lookup to return the exact match,
not just the first possible match.
* distribution-Makefile (INFODIR): Changed to default location for
Emacs installations.
(LISPDIR): Same here.
Sat Sep 2 14:24:57 2000 David Byers <davby@sen2.ida.liu.se>
* slow.el (lyskom-expand-slow-command): Use
lyskom-slow-list-completions to sort possible completions.
(lyskom-slow-list-completions): New function.
......@@ -18,8 +17,6 @@ Sat Sep 2 14:24:57 2000 David Byers <davby@sen2.ida.liu.se>
* compatibility.el (char-before): New compatibility definition.
2000-09-02 David Byers <davby@sen2.ida.liu.se>
* utilities.el (lyskom-maybe-frob-completion-table): Add third
argument to lyskom-recode-string.
......
......@@ -205,13 +205,6 @@
"Reads and returns a command"
(let* ((completion-ignore-case t)
(minibuffer-setup-hook minibuffer-setup-hook)
;;; (alternatives (mapcar
;;; (lambda (pair)
;;; (cons
;;; (cdr pair)
;;; (car pair)))
;;; (lyskom-get-strings lyskom-commands
;;; 'lyskom-command)))
(name nil)
(prefix-text
(cond ((eq prefix-arg '-) "- ")
......@@ -256,11 +249,26 @@ transformed for matching."
(lyskom-complete-command string predicate 'lyskom-lookup))
(defsubst lyskom-command-match-string-regexp (string)
(concat "^"
(replace-in-string (regexp-quote (lyskom-unicase (lyskom-completing-strip-name string t)))
"\\s-+" "\\\\S-*\\\\s-+")
(concat
"^"
(replace-in-string (regexp-quote
(lyskom-unicase
(lyskom-completing-strip-command string)))
"\\s-+" "\\\\S-*\\\\s-+")
"\\s-*"))
(defun lyskom-completing-strip-command (string)
"Strip parens and crap from a name.
If optional DONT-STRIP-SPACES is non-nil, don't strip spaces at front
and back of the string."
(while (string-match "([^()]*)" string) ; Strip nested parens
(setq string (replace-match " " t t string)))
(while (string-match "\\s-\\s-+" string) ; Collapse spaces
(setq string (replace-match " " t t string)))
(while (string-match "([^()]*$" string) ; Strip incomplete parens at end
(setq string (substring string 0 (match-beginning 0))))
string)
(defun lyskom-complete-command (string predicate all)
"Completion function for LysKOM commands."
(let ((alternatives nil)
......
......@@ -550,18 +550,15 @@ function work as a name-to-conf-stat translator."
result))
(defun lyskom-completing-strip-name (string &optional dont-strip-spaces)
"Strip parens and crap from a name.
If optional DONT-STRIP-SPACES is non-nil, don't strip spaces at front
and back of the string."
(defun lyskom-completing-strip-name (string)
"Strip parens and crap from a name."
(while (string-match "([^()]*)" string)
(setq string (replace-match " " t t string)))
(while (string-match "\\s-\\s-+" string)
(setq string (replace-match " " t t string)))
(while (string-match "([^()]*$" string)
(setq string (substring string 0 (match-beginning 0))))
(if (and (not dont-strip-spaces)
(string-match "^\\s-*\\(.*\\S-\\)\\s-*$" string))
(if (string-match "^\\s-*\\(.*\\S-\\)\\s-*$" string)
(match-string 1 string)
string))
......
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