Commit cf211aec authored by David Kågedal's avatar David Kågedal
Browse files

* swedish-strings.el (lyskom-parse-command-and-execute): Bort med

swascii och lite kosmetiska fixar.
(kom-expand-slow-command): Ny funktion.
(kom-parse-command-and-execute): Bytte namn från
lyskom-parse-command-and-execute.
(lyskom-get-entered-slow-command): Ny funktion.
(kom-expand-slow-or-next-command): Ny funktion.
parent 8dec4a04
Fri Aug 9 01:18:34 1996 David Kgedal <davidk@lysator.liu.se>
* swedish-strings.el (lyskom-parse-command-and-execute): Bort med
swascii och lite kosmetiska fixar.
(kom-expand-slow-command): Ny funktion.
(kom-parse-command-and-execute): Bytte namn frn
lyskom-parse-command-and-execute.
(lyskom-get-entered-slow-command): Ny funktion.
(kom-expand-slow-or-next-command): Ny funktion.
Thu Aug 8 12:33:03 1996 David Byers <davby@sen2.ida.liu.se>
* english-strings.el, swedish-strings.el (lyskom-strings): Lade
......
......@@ -1609,11 +1609,15 @@ This variable is stored in the LysKOM server.")
(make-sparse-keymap)
"Mode map for the `slow' lyskom command mode.")
(define-key lyskom-slow-mode-map "\r" 'lyskom-parse-command-and-execute)
(define-key lyskom-slow-mode-map "\r" 'kom-parse-command-and-execute)
(define-key lyskom-slow-mode-map "\t" 'kom-expand-slow-command)
(define-key lyskom-slow-mode-map " " 'kom-expand-slow-or-next-command)
(defun lyskom-parse-command-and-execute ()
"Reads a command from the last line in the buffer and executes it."
(interactive)
(defun lyskom-get-entered-slow-command ()
"Get the text that the user has entered after the last prompt.
Note that this function leaves point at the end of the prompt.
If no text is entered, nil is returned."
(goto-char (point-max))
(save-restriction
(narrow-to-region lyskom-last-viewed (point-max))
......@@ -1621,33 +1625,79 @@ This variable is stored in the LysKOM server.")
(forward-char (length lyskom-prompt-text))
(while (looking-at "\\s-")
(forward-char 1))
(let* ((text (buffer-substring (point) (point-max)))
(if (= (point) (point-max))
nil
(buffer-substring (point) (point-max))))
(defun kom-expand-slow-command ()
"Tries to complete the command at point.
If the completion was exact return a pair `(COMMAND . POINT)' where
COMMAND is the command and POINT is the point where the command text
starts.
If the completion was not exact it returns nil."
(interactive)
(let* ((text (lyskom-get-entered-slow-command))
(completion-ignore-case t)
(alternatives (mapcar (function reverse)
(alternatives (mapcar 'reverse
(if kom-emacs-knows-iso-8859-1
lyskom-commands
lyskom-swascii-commands)))
(completes (all-completions text alternatives)))
(completes (and text (all-completions text alternatives)))
(command nil))
(cond
((zerop (length text))
(kom-next-command))
((> (length completes) 1)
(lyskom-insert "\nDu kan mena n}gon av f|ljande:\n")
(mapcar (function (lambda (string)
(lyskom-insert string)
(lyskom-insert "\n")))
completes)
(lyskom-end-of-command))
((null text)
(lyskom-beep t))
((null completes)
(lyskom-insert-before-prompt
"Det finns inget s\345dant kommando.\n")
(lyskom-beep t))
((= (length completes) 1)
(delete-region (point) (point-max))
(call-interactively (car (reverse-assoc (car completes)
(setq command (cons (car (reverse-assoc (car completes)
(if kom-emacs-knows-iso-8859-1
lyskom-commands
lyskom-swascii-commands)))))
(t
(lyskom-insert "Det finns inget s}dant kommando.\n")
(lyskom-end-of-command)))
))
lyskom-swascii-commands)))
(point)))
(delete-region (point) (point-max))
(insert (car completes)))
((> (length completes) 1)
(let ((longest (try-completion text alternatives)))
(cond
((eq longest 't)
(delete-region (point) (point-max))
(insert (car completes)))
((stringp longest)
(if (string= (upcase longest) (upcase text))
(lyskom-insert-before-prompt
(concat "Du kan mena n\345gon av f\366ljande:\n "
(mapconcat 'identity completes "\n ")
"\n")))
(delete-region (point) (point-max))
(insert longest))
(t (signal 'lyskom-internal-error '()))))))
command))
(defun kom-expand-slow-or-next-command ()
"If any part of a slow command has been entered, call
`kom-expand-slow-command'. Otherwise, do `kom-next-command'."
(interactive)
(if (lyskom-get-entered-slow-command)
(kom-expand-slow-command)
(kom-next-command)))
(defun kom-parse-command-and-execute ()
"Reads a command from the last line in the buffer and executes it."
(interactive)
(let* ((text (lyskom-get-entered-slow-command))
(command (and text (kom-expand-slow-command))))
(cond
((null text)
(call-interactively 'kom-next-command))
(command
(delete-region (cdr command) (point-max))
(call-interactively (car command))))))
(defun kom-slow-mode ()
......
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