Commit 39b0a08f authored by David Byers's avatar David Byers

Reimplementation of kom-next-link, kom-prev-link, backward-text and forward-text.

New commands kom-next-prompt, kom-prev-prompt.
parent 048fd46a
1999-10-14 David Byers <davby@ida.liu.se>
* english-strings.el, swedish-strings.el, vars.el.in: Removed
variable lyskom-text-start.
* lyskom-rest.el (backward-text): Implement using
lyskom-prev-area.
(forward-text): Implement using lyskom-next-area.
(lyskom-text-at-point): Implement using lyskom-prev-area.
* view-text.el (lyskom-view-text): Insert property
lyskom-text-start on the number of each newly inserted text.
* utilities.el (lyskom-prev-area): New function.
(lyskom-next-area): New function.
* lyskom-rest.el (kom-prev-prompt): New function.
(kom-next-prompt): New function.
* lyskom-buttons.el (kom-previous-link): Implement using
lyskom-prev-area.
(kom-next-link): Implement using lyskom-next-area.
* english-strings.el (lyskom-text-start): Updated to work with
imported texts.
......
......@@ -772,9 +772,6 @@ Help: \\[describe-mode] ---")
(marked-by-you-and-others . "Marked by you and %#1?d%[someone else%]%[%#1d others%].\n")
(marked-by-several . "Marked by %#1d user%#1?d%[%]%[s%].\n")
;; The format of this function should coincide with the format of the
;; lyskom-text-start variable. DONT change one without changing the other.
(time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d")
; used by lyskom-print-time
......@@ -1721,16 +1718,6 @@ You must become an active member of the conference to enter it.\n")
(dontshow . "Don't show")
(skip-tree . "Skip comments")))
;;(defvar lyskom-swascii-filter-actions nil
;; "The swascii-versions of lyskom-filter-actions.")
;;(defvar lyskom-swascii-filter-what nil
;; "The swascii version of lyskom-filter-what")
(lyskom-language-var lyskom-text-start en
"[0-9]+ +\\(199[0-9]-[0-1][0-9]-[0-3][0-9]\\|today\\|yesterday\\) +[0-2][0-9]:[0-5][0-9] +\\([-+][0-9][0-9][0-9][0-9] +\\)?/[0-9]+ line\\(s\\)?/ ")
(defconst lyskom-keybindings-missing nil)
(defvar lyskom-en-mode-map nil)
......@@ -1866,6 +1853,8 @@ You must become an active member of the conference to enter it.\n")
(define-key lyskom-en-mode-map (kbd "M-p") 'backward-text)
(define-key lyskom-en-mode-map (kbd "M-n") 'forward-text)
(define-key lyskom-sv-mode-map (kbd "C-M-p") 'kom-prev-prompt)
(define-key lyskom-sv-mode-map (kbd "C-M-n") 'kom-next-prompt)
(define-key lyskom-en-mode-map (kbd "s a") 'kom-save-text)
(define-key lyskom-en-mode-map (kbd "C-?") 'scroll-down)
......
......@@ -82,36 +82,12 @@ on such functions see the documentation for lyskom-add-button-action."
(defun kom-previous-link (num)
"Move the cursor to the previous active area in the LysKOM buffer."
(interactive "p")
(while (> num 0)
(let ((where (previous-single-property-change (point)
'lyskom-button-text)))
(if where
(progn
(if (not (get-text-property where 'lyskom-button-text))
(setq where (previous-single-property-change
where
'lyskom-button-text)))
(if where
(goto-char where)
(goto-char (point-min))
(setq num 1)))))
(setq num (1- num))))
(lyskom-prev-area num 'lyskom-button-text))
(defun kom-next-link (num)
"Move the cursor to the next active area in the LysKOM buffer."
(interactive "p")
(while (> num 0)
(let ((where (next-single-property-change (point) 'lyskom-button-text)))
(if where
(progn
(if (not (get-text-property where 'lyskom-button-text))
(setq where (next-single-property-change where
'lyskom-button-text)))
(if where
(goto-char where)
(goto-char (point-max))
(setq num 1)))))
(setq num (1- num))))
(lyskom-next-area num 'lyskom-button-text))
(defun kom-button-press ()
......
......@@ -2138,30 +2138,33 @@ A list of pairs means OPTARG will be used as a key to look up the real
(defun lyskom-text-at-point ()
"Return the text that point is in, or nil it is impossible to determine."
(save-excursion
(let ((paragraph-start lyskom-text-start)
(paragraph-ignore-fill-prefix t))
(end-of-line)
(backward-paragraph 1))
(beginning-of-line)
(and (looking-at "[0-9]+")
(string-to-int (match-string 0)))))
(lyskom-prev-area 1 'lyskom-text-start)
(get-text-property (point) 'lyskom-text-start)))
(defun kom-next-prompt (num)
"Move the cursor to the next prompt in the LysKOM buffer"
(interactive "p")
(lyskom-next-area num 'lyskom-prompt))
(defun kom-prev-prompt (num)
"Move the cursor to the previous prompt in the LysKOM buffer"
(interactive "p")
(beginning-of-line)
(lyskom-prev-area num 'lyskom-prompt))
(defun backward-text (&optional arg)
"Searches backwards for a text start and recenters with that text at the top."
(interactive "p")
(let ((paragraph-start lyskom-text-start)
(paragraph-ignore-fill-prefix t))
(backward-paragraph arg))
(lyskom-prev-area (or arg 1) 'lyskom-text-start)
(beginning-of-line))
(defun forward-text (&optional arg)
"Searches forward for a text start and recenters with that text at the top."
(interactive "p")
(let ((paragraph-start lyskom-text-start)
(paragraph-ignore-fill-prefix t))
(forward-paragraph arg)))
(lyskom-next-area (or arg 1) 'lyskom-text-start))
(def-kom-command kom-save-text (&optional arg)
......@@ -2376,18 +2379,20 @@ Set lyskom-current-prompt accordingly. Tell server what I am doing."
(lyskom-set-mode-line)))
(defun lyskom-modify-prompt (s &optional executing)
(lyskom-format-prompt (cond (lyskom-is-administrator
(if executing
kom-enabled-prompt-format-executing
kom-enabled-prompt-format))
(lyskom-is-anonymous
(if executing
kom-anonymous-prompt-format-executing
kom-anonymous-prompt-format))
(t (if executing
kom-user-prompt-format-executing
kom-user-prompt-format)))
s))
(let ((text (lyskom-format-prompt (cond (lyskom-is-administrator
(if executing
kom-enabled-prompt-format-executing
kom-enabled-prompt-format))
(lyskom-is-anonymous
(if executing
kom-anonymous-prompt-format-executing
kom-anonymous-prompt-format))
(t (if executing
kom-user-prompt-format-executing
kom-user-prompt-format)))
s)))
(add-text-properties 0 (length text) '(lyskom-prompt t) text)
text))
......
......@@ -780,10 +780,6 @@ Annat se \\[describe-mode] ---")
(marked-by-you-and-others . "Markerad av dig och %#1?d%[ngon annan%]%[%#1d andra%].\n")
(marked-by-several . "Markerad av %#1d person%#1?d%[%]%[er%].\n")
;; The format of this function should coincide with the
;; format of the lyskom-text-start variable. DONT change
;; one without changing the other.
(time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d")
;; used by lyskom-print-time
......@@ -1734,14 +1730,6 @@ Du m
(dontshow . "Visa inte")
(skip-tree . "Hoppa ver kommentarer")))
;;(defvar lyskom-swascii-filter-actions nil
;; "The swascii-versions of lyskom-filter-actions.")
;;(defvar lyskom-swascii-filter-what nil
;; "The swascii version of lyskom-filter-what")
(lyskom-language-var lyskom-text-start sv
"[0-9]+ +\\(199[0-9]-[0-1][0-9]-[0-3][0-9]\\|idag\\|igr\\) +[0-2][0-9]:[0-5][0-9] +\\([-+][0-9][0-9][0-9][0-9] +\\)?/[0-9]+ rad\\(er\\)?/ ")
(defconst lyskom-keybindings-missing '(lyskom-previous-prefix))
......@@ -1906,6 +1894,8 @@ Du m
(define-key lyskom-sv-mode-map (kbd "M-p") 'backward-text)
(define-key lyskom-sv-mode-map (kbd "M-n") 'forward-text)
(define-key lyskom-sv-mode-map (kbd "C-M-p") 'kom-prev-prompt)
(define-key lyskom-sv-mode-map (kbd "C-M-n") 'kom-next-prompt)
(define-key lyskom-sv-mode-map (kbd "s t") 'kom-save-text)
(define-key lyskom-sv-mode-map (kbd "C-?") 'scroll-down)
......
......@@ -701,3 +701,30 @@ return nil."
(setq found (length (cdr (read-info->text-list (car rlist))))))
(setq rlist (cdr rlist)))
found)))
(defun lyskom-prev-area (num prop)
(while (> num 0)
(let ((where (previous-single-property-change (point) prop)))
(when where
(if (not (get-text-property where prop))
(setq where (previous-single-property-change
where prop)))
(if where
(goto-char where)
(goto-char (point-min))
(setq num 1))))
(setq num (1- num))))
(defun lyskom-next-area (num prop)
"Move the cursor to the next prompt in the LysKOM buffer"
(interactive "p")
(while (> num 0)
(let ((where (next-single-property-change (point) prop)))
(when where
(if (not (get-text-property where prop))
(setq where (next-single-property-change where prop)))
(if where
(goto-char where)
(goto-char (point-max))
(setq num 1))))
(setq num (1- num))))
......@@ -966,10 +966,6 @@ at random and used. This element may be a string, function or list."
"A list of legal filter actions an their textual representation."
local)
(def-kom-var lyskom-text-start nil
"Regexp matching beginning of a text in lyskom buffer.
Cf. paragraph-start.")
(def-kom-var lyskom-filter-edit-map nil
"Keymap for LysKOM filter edit"
local)
......
......@@ -91,7 +91,8 @@ Note that this function must not be called asynchronously."
;; Use a marker, because the buffer may lose data
;; at the top if kom-max-buffer-size is set.
(setq start (point-max-marker))
(lyskom-format-insert "%#1n " text-stat)
(lyskom-format-insert "%#2@%[%#1n%] " text-stat (list 'lyskom-text-start
(text-stat->text-no text-stat)))
(let ((mx-date (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 21)))
(mx-from (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 17)))
(mx-author (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 16)))
......
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