Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
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> Thu Aug 8 12:33:03 1996 David Byers <davby@sen2.ida.liu.se>
* english-strings.el, swedish-strings.el (lyskom-strings): Lade * english-strings.el, swedish-strings.el (lyskom-strings): Lade
......
...@@ -1609,11 +1609,15 @@ This variable is stored in the LysKOM server.") ...@@ -1609,11 +1609,15 @@ This variable is stored in the LysKOM server.")
(make-sparse-keymap) (make-sparse-keymap)
"Mode map for the `slow' lyskom command mode.") "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 () (defun lyskom-get-entered-slow-command ()
"Reads a command from the last line in the buffer and executes it." "Get the text that the user has entered after the last prompt.
(interactive) Note that this function leaves point at the end of the prompt.
If no text is entered, nil is returned."
(goto-char (point-max)) (goto-char (point-max))
(save-restriction (save-restriction
(narrow-to-region lyskom-last-viewed (point-max)) (narrow-to-region lyskom-last-viewed (point-max))
...@@ -1621,33 +1625,79 @@ This variable is stored in the LysKOM server.") ...@@ -1621,33 +1625,79 @@ This variable is stored in the LysKOM server.")
(forward-char (length lyskom-prompt-text)) (forward-char (length lyskom-prompt-text))
(while (looking-at "\\s-") (while (looking-at "\\s-")
(forward-char 1)) (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) (completion-ignore-case t)
(alternatives (mapcar (function reverse) (alternatives (mapcar 'reverse
(if kom-emacs-knows-iso-8859-1 (if kom-emacs-knows-iso-8859-1
lyskom-commands lyskom-commands
lyskom-swascii-commands))) lyskom-swascii-commands)))
(completes (all-completions text alternatives))) (completes (and text (all-completions text alternatives)))
(command nil))
(cond (cond
((zerop (length text)) ((null text)
(kom-next-command)) (lyskom-beep t))
((> (length completes) 1) ((null completes)
(lyskom-insert "\nDu kan mena n}gon av f|ljande:\n") (lyskom-insert-before-prompt
(mapcar (function (lambda (string) "Det finns inget s\345dant kommando.\n")
(lyskom-insert string) (lyskom-beep t))
(lyskom-insert "\n")))
completes)
(lyskom-end-of-command))
((= (length completes) 1) ((= (length completes) 1)
(delete-region (point) (point-max)) (setq command (cons (car (reverse-assoc (car completes)
(call-interactively (car (reverse-assoc (car completes)
(if kom-emacs-knows-iso-8859-1 (if kom-emacs-knows-iso-8859-1
lyskom-commands lyskom-commands
lyskom-swascii-commands))))) lyskom-swascii-commands)))
(t (point)))
(lyskom-insert "Det finns inget s}dant kommando.\n") (delete-region (point) (point-max))
(lyskom-end-of-command))) (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 () (defun kom-slow-mode ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment