Commit cad928d3 authored by David Byers's avatar David Byers
Browse files

Fixed bug 475 (manipulate and navigate active areas in the edit buffer

using the keyboard).
Fixed bug 483 (make the new add button optional)
parent 25a25a48
2002-04-26 David Byers <david.byers@swipnet.se>
* option-edit.el (lyskom-custom-variables): Added
kom-edit-hide-add-button.
(lyskom-customize-buffer-format): Added kom-edit-hide-add-button.
* vars.el.in (kom-edit-hide-add-button): New variable.
* edit-text.el (lyskom-edit-insert-aux-item): Number of lines to
back up depends on kom-edit-hide-add-button.
(lyskom-edit-insert-miscs): Insert add button only if
kom-edit-hide-add-button is nil.
Fix bug 475:
* edit-text.el (kom-ispell-message): Don't search for
ispell-message-start-skip unless it is a string.
New command.
(kom-edit-prev-button): New command.
(lyskom-edit-find-separator): New function. Extracted code that
finds the separator line.
(kom-ispell-message): Use it.
(lyskom-edit-insert-aux-item): Use it.
(lyskom-edit-replace-headers): Use it.
(lyskom-edit-parse-headers): Use it.
(lyskom-edit-extract-text): Use it.
(lyskom-edit-on-aux-item): Use it.
(lyskom-edit-fcc-text): Use it.
* english-strings.el, swedish-strings.el: Bind * and = in
lyskom-edit-mode-map to kom-button-click-or-self-insert and
kom-button-press-or-self-insert respectively. Bind TAB and M-TAB
to kom-edit-next-button-or-self-insert and kom-edit-prev-button
respectively.
* lyskom-buttons.el (kom-button-press-or-self-insert-command): New
function.
(kom-menu-button-press-or-self-insert-command): New function.
2002-04-25 David Byers <david.byers@swipnet.se>
* view-text.el (lyskom-print-text): Use kom-highlight-text-body to
......
......@@ -170,6 +170,22 @@ Does lyskom-end-of-command."
)
(defun lyskom-edit-find-separator (&optional move-point)
"Return the end position of the separator line.
If MOVE-POINT is non-nil, move point to the start of the separator."
(prog1
(save-excursion
(goto-char (point-min))
(and (re-search-forward
(concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil t)))
(when (and move-point (match-beginning 0))
(goto-char (match-beginning 0)))))
(defun lyskom-edit-insert-miscs (misc-list subject body &optional aux-list)
"Insert MISC-LIST into header of text.
......@@ -224,11 +240,12 @@ nil -> Ingenting."
(lyskom-get-string 'aux-item-prefix))
where-put-misc)))))
aux-list)
(unless kom-edit-hide-add-button
(lyskom-princ (lyskom-format "%[%#1@%#2s%]\n"
(lyskom-default-button 'add-recipient-or-xref
edit-buffer)
(lyskom-get-string 'add-recpt-button-text))
where-put-misc)
where-put-misc))
(lyskom-princ (lyskom-format 'text-mass subject
(substitute-command-keys
(lyskom-get-string 'header-separator))
......@@ -343,71 +360,6 @@ This one differs from lyskom-edit-mode-hook in that it is called before
the lyskom-special key bindings are added.")
;;;(defun lyskom-edit-mode ()
;;; "\\<lyskom-edit-mode-map>Mode for editing texts for LysKOM.
;;;Commands:
;;;\\[kom-edit-send] sends the text when you are ready. The buffer will be
;;; deleted if (and only if) the server accepts the text.
;;;\\[kom-edit-quit] aborts the editing. You will get back to the LysKOM buffer.
;;;
;;;\\[kom-edit-show-commented] shows the commented text in a temporary buffer.
;;;
;;;\\[kom-edit-add-recipient] asks for another recipient and adds him to the header.
;;;\\[kom-edit-add-copy] as \\[kom-edit-add-recipient] but adds him as copy-recipient.
;;;
;;;\\[kom-edit-insert-commented] inserts the commented of footnoted text.
;;;\\[kom-edit-insert-text] inserts the shown text, you tell the number."
;;; (interactive)
;;; (let ((tmp-keymap nil))
;;; (kill-all-local-variables)
;;; (text-mode)
;;;
;;; (run-hooks 'lyskom-edit-mode-mode-hook)
;;;
;;; (setq tmp-keymap (and (current-local-map)
;;; (copy-keymap (current-local-map))))
;;;
;;; (lyskom-set-menus 'lyskom-edit-mode lyskom-edit-mode-map)
;;; (setq mode-line-buffer-identification '("LysKOM (server: %b)"))
;;; (setq major-mode 'lyskom-edit-mode)
;;; (setq mode-name lyskom-edit-mode-name)
;;;
;;; (if tmp-keymap
;;; (let ((new-keymap (make-sparse-keymap)))
;;; (make-local-variable 'lyskom-edit-mode-map)
;;; (setq lyskom-edit-mode-map
;;; (lyskom-default-value 'lyskom-edit-mode-map))
;;;
;;; (lyskom-xemacs-or-gnu
;;; (set-keymap-parents new-keymap
;;; (list lyskom-edit-mode-map
;;; tmp-keymap))
;;; (progn (set-keymap-parent new-keymap lyskom-edit-mode-map)
;;; (lyskom-overlay-keymap lyskom-edit-mode-map
;;; tmp-keymap
;;; new-keymap)))
;;; (use-local-map new-keymap))
;;;
;;; (lyskom-use-local-map lyskom-edit-mode-map))
;;;
;;;
;;; (auto-save-mode 1)
;;; (auto-fill-mode 1)
;;; (make-local-variable 'paragraph-start)
;;; (make-local-variable 'paragraph-separate)
;;; (setq paragraph-start (concat "^"
;;; (regexp-quote
;;; (substitute-command-keys
;;; (lyskom-get-string 'header-separator)))
;;; "$\\|" paragraph-start))
;;; (setq paragraph-separate (concat "^"
;;; (regexp-quote
;;; (substitute-command-keys
;;; (lyskom-get-string 'header-separator)))
;;; "$\\|" paragraph-separate))
;;; (run-hooks 'lyskom-edit-mode-hook)))
(defun lyskom-edit-mode (&optional arg)
"\\<lyskom-edit-mode-map>Mode for editing texts for LysKOM.
Commands:
......@@ -708,15 +660,7 @@ Based on ispell-message."
(save-excursion
(goto-char (point-min))
(let* ((internal-messagep
(save-excursion
(re-search-forward
(concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil t)))
(let* ((internal-messagep (lyskom-edit-find-separator t))
(limit
(copy-marker
(cond ((not ispell-message-text-end) (point-max))
......@@ -760,6 +704,7 @@ Based on ispell-message."
(match-beginning 0)))
(end-fwd (and (goto-char start)
(boundp 'ispell-message-start-skip)
(stringp ispell-message-start-skip)
(re-search-forward ispell-message-start-skip
limit 'end)))
(end (or (and end-c end-fwd (min end-c end-fwd))
......@@ -1420,16 +1365,8 @@ RECPT-TYPE is the type of recipient to add."
(defun lyskom-edit-insert-aux-item (item)
"Insert the aux item ITEM in the current buffer"
(save-excursion
(goto-char (point-min))
(re-search-forward
(concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil t)
(beginning-of-line)
(forward-line -2)
(lyskom-edit-find-separator t)
(forward-line (if kom-edit-hide-add-button -1 -2))
(insert
(concat (lyskom-format
(format "%%#1@%%[%s%%] %%#2s" (lyskom-get-string 'aux-item-prefix))
......@@ -1550,11 +1487,7 @@ to lyskom-edit-replace-headers"
(goto-char (point-min))
(setq start (point-marker))
(set-marker-insertion-type start t)
(re-search-forward (concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$"))
(lyskom-edit-find-separator t)
(end-of-line)
(setq end (point-marker))
(goto-char (point-min))
......@@ -1595,12 +1528,7 @@ easy to use the result in a call to `lyskom-create-misc-list'."
(aux nil))
(save-restriction
;; Narrow to headers
(re-search-forward (concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$"))
(beginning-of-line)
(lyskom-edit-find-separator t)
(narrow-to-region (point-min) (point))
(goto-char (point-min))
(while (< (point) (point-max))
......@@ -1687,15 +1615,10 @@ Point must be located on the line where the subject is."
(defun lyskom-edit-extract-text ()
"Get text as a string."
(save-excursion
(goto-char (point-min))
(if (not (re-search-forward (concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil (point-max)))
(if (not (lyskom-edit-find-separator t))
(signal 'lyskom-internal-error
"Altered lyskom-header-separator line.")
(end-of-line)
(buffer-substring (1+ (point))
(progn
(goto-char (1- (point-max)))
......@@ -1710,12 +1633,7 @@ Point must be located on the line where the subject is."
(save-excursion
(beginning-of-line)
(and (lyskom-looking-at (lyskom-get-string 'aux-item-prefix-regexp))
(re-search-forward (concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil (point-max)))))
(> (lyskom-edit-find-separator) (point)))))
(defun lyskom-create-text-handler (text-no edit-buffer
......@@ -1816,14 +1734,7 @@ Point must be located on the line where the subject is."
(erase-buffer)
(insert text)
(goto-char (point-min))
(when (re-search-forward
(concat "^"
(regexp-quote
(substitute-command-keys
(lyskom-get-string 'header-separator)))
"$")
nil t)
(goto-char (match-beginning 0))
(when (lyskom-edit-find-separator t)
(delete-region (match-beginning 0) (match-end 0))
(insert (make-string kom-text-header-dash-length ?-))
(forward-line 1)
......@@ -1977,61 +1888,42 @@ buglist style, automating the removal of closed subjects and change-marks."
;;; ================================================================
;;; Maphanteringsfunktion - keymap handling.
;;;
;;; Author: Linus Tolke
;;;
(defun overlay-map (oldmap newmap)
"Returns a map that is the union of OLDMAP and NEWMAP. NEW-MAP has priority.
This function chooses whether the returned map is a list or an array.
Currently always same type as oldmap.
BUG: does not descend in the maps."
(cond
((not (keymapp oldmap))
newmap)
((not (keymapp newmap))
oldmap)
(t
(let ((map (copy-keymap oldmap))
(r 0))
(cond
((fboundp 'map-keymap) ;Special for lucid-emacs
(map-keymap
(function
(lambda (event function)
(define-key map (vector event) function)))
newmap))
((and (string-match "^19" emacs-version)
(arrayp (car (cdr newmap))))
(while (< r (length (car (cdr newmap))))
(if (aref (car (cdr newmap)) r)
(define-key map (char-to-string r) (aref (car (cdr newmap)) r)))
(setq r (1+ r)))
(mapcar
(function
(lambda (ele)
(define-key map
(cond
((integerp (car ele))
(char-to-string (car ele)))
((vector (car ele))))
(cdr ele))))
(cdr (cdr newmap))))
((arrayp newmap)
(while (< r (length newmap))
(if (aref newmap r)
(define-key map (char-to-string r) (aref newmap r)))
(setq r (1+ r))))
(t
(mapcar
(function
(lambda (ele)
(define-key map
(cond
((integerp (car ele))
(char-to-string (car ele)))
((vector (car ele))))
(cdr ele))))
(cdr newmap))))
map))))
;;; Tab between buttons in the header
(defun kom-edit-next-button-or-self-insert (num)
(interactive "p")
(let ((header-end (lyskom-edit-find-separator))
(start (point))
(next-pos nil))
(if (> (point) header-end)
(call-interactively 'self-insert-command)
(while (> num 0)
(lyskom-next-area 1 'lyskom-button)
(if (eq start (point))
(setq next-pos nil)
(setq next-pos (point)))
(cond ((or (null next-pos)
(> next-pos header-end))
(goto-char start)
(unless (re-search-forward (regexp-quote (lyskom-get-string
'header-subject))
header-end
t)
(goto-char (point-max))
(setq num 0)))
(t (goto-char next-pos)))
(setq num (1- num) start (point))))))
(defun kom-edit-prev-button (num)
(interactive "p")
(let ((header-end (lyskom-edit-find-separator)))
(while (> num 0)
(cond ((and (> (point) header-end)
(progn (goto-char (point-min))
(re-search-forward (regexp-quote (lyskom-get-string
'header-subject))
header-end
t)))
(setq num (1- num)))
(t (lyskom-prev-area num 'lyskom-button)
(setq num 0))))))
......@@ -30,7 +30,6 @@
;;;;
;;;; This file contains all strings in the LysKOM elisp client.
;;;; Language: English.
;;;; Matches version 36.11 of swedish-strings.el
;;;; ================================================================
;;;;
;;;; Translation from swedish-strings.el: David Byers
......@@ -75,6 +74,10 @@
(define-key lyskom-en-edit-mode-map (kbd (lyskom-keys (lyskom-xemacs-or-gnu 'button2up 'button2))) 'kom-mouse-null)
(define-key lyskom-en-edit-mode-map (kbd (lyskom-keys 'button3)) 'kom-popup-menu)
(define-key lyskom-en-edit-mode-map (kbd (lyskom-keys 'button3up)) 'kom-mouse-null)
(define-key lyskom-en-edit-mode-map (kbd "*") 'kom-button-press-or-self-insert-command)
(define-key lyskom-en-edit-mode-map (kbd "=") 'kom-menu-button-press-or-self-insert-command)
(define-key lyskom-en-edit-mode-map (kbd "TAB") 'kom-edit-next-button-or-self-insert)
(define-key lyskom-en-edit-mode-map (kbd "M-TAB") 'kom-edit-prev-button)
(define-key lyskom-en-edit-mode-map (kbd "C-c") 'lyskom-en-edit-prefix)
(define-key lyskom-en-edit-prefix (kbd "C-x") 'lyskom-en-edit-aux-prefix)
(define-key lyskom-en-edit-prefix (kbd "?") 'lyskom-help)
......@@ -82,7 +85,7 @@
(define-key lyskom-en-edit-prefix (kbd "C-i") 'lyskom-en-edit-insert-prefix)
(define-key lyskom-en-edit-prefix (kbd "TAB") 'lyskom-en-edit-insert-prefix)
(define-key lyskom-en-edit-prefix (kbd "*") 'kom-button-press)
(define-key lyskom-en-edit-prefix (kbd "+") 'kom-menu-button-press)
(define-key lyskom-en-edit-prefix (kbd "=") 'kom-menu-button-press)
(define-key lyskom-en-edit-prefix (kbd "C-c") 'kom-edit-send)
(define-key lyskom-en-edit-prefix (kbd "C-s") 'kom-ispell-message)
(define-key lyskom-en-edit-prefix (kbd "C-k") 'kom-edit-quit)
......@@ -2124,7 +2127,7 @@ Number of sessions: %21#1d (total)
(define-key lyskom-en-mode-map (kbd (lyskom-keys 'button2up)) 'kom-mouse-null)
(define-key lyskom-en-mode-map (kbd (lyskom-keys 'button3up)) 'kom-mouse-null)
(define-key lyskom-en-mode-map (kbd "*") 'kom-button-press)
(define-key lyskom-en-mode-map (kbd "+") 'kom-menu-button-press)
(define-key lyskom-en-mode-map (kbd "=") 'kom-menu-button-press)
(define-key lyskom-en-mode-map (kbd "TAB") 'kom-next-link)
(define-key lyskom-en-mode-map (kbd "M-TAB") 'kom-previous-link)
......@@ -3458,6 +3461,9 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(kom-highlight-text-body-doc . "\
When this is on, the text body is shown with a different format than
normal text.")
(kom-edit-hide-add-button-doc . "\
When this is on, an [Add...] button will be shown after the list of
recipients and auxiliary information when writing a new text.")
;;
......@@ -3630,6 +3636,7 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(kom-highlight-first-line-tag . "Color fist line:")
(kom-highlight-dashed-lines-tag . "Color dashed lines:")
(kom-highlight-text-body-tag . "Color text backgrounds:")
(kom-edit-hide-add-button-tag . "Show add button when writing texts:")
)
)
......
......@@ -90,11 +90,26 @@ on such functions see the documentation for lyskom-add-button-action."
(lyskom-next-area num 'lyskom-button))
(defun kom-button-press-or-self-insert-command ()
"Simulate a mouse button press at point, if there is a button."
(interactive)
(if (get-text-property (point) 'lyskom-button)
(call-interactively 'kom-button-press)
(call-interactively 'self-insert-command)))
(defun kom-button-press ()
"Simulate a mouse button press at point."
(interactive)
(lyskom-button-press (point)))
(defun kom-menu-button-press-or-self-insert-command ()
"Simulate a menu mouse button press at point, if there is a button."
(interactive)
(if (get-text-property (point) 'lyskom-button)
(call-interactively 'kom-menu-button-press)
(call-interactively 'self-insert-command)))
(defun kom-menu-button-press ()
"Simulate a menu mouse button press at point."
(interactive)
......
......@@ -204,6 +204,7 @@
(writing bold centered)
section
"\n"
[kom-edit-hide-add-button]
[kom-cite-string]
[kom-ispell-dictionary]
"\n"
......@@ -705,6 +706,7 @@ customize buffer but do not save them to the server."
(kom-print-relative-dates (toggle (yes no)))
(kom-print-seconds-in-time-strings (toggle (yes no)))
(kom-extended-status-information (toggle (yes no)))
(kom-edit-hide-add-button (noggle (yes no)))
))
(defvar lyskom-widget-functions
......
......@@ -69,6 +69,10 @@
(define-prefix-command 'lyskom-sv-edit-insert-prefix)
(define-prefix-command 'lyskom-sv-edit-aux-prefix)
(define-prefix-command 'lyskom-sv-edit-add-prefix)
(define-key lyskom-sv-edit-mode-map (kbd "*") 'kom-button-press-or-self-insert-command)
(define-key lyskom-sv-edit-mode-map (kbd "=") 'kom-menu-button-press-or-self-insert-command)
(define-key lyskom-sv-edit-mode-map (kbd "TAB") 'kom-edit-next-button-or-self-insert)
(define-key lyskom-sv-edit-mode-map (kbd "M-TAB") 'kom-edit-prev-button)
(define-key lyskom-sv-edit-mode-map (kbd "C-c") 'lyskom-sv-edit-prefix)
(define-key lyskom-sv-edit-mode-map (kbd (lyskom-keys (lyskom-xemacs-or-gnu 'button2 'button2up))) 'kom-button-click-or-yank)
(define-key lyskom-sv-edit-mode-map (kbd (lyskom-keys (lyskom-xemacs-or-gnu 'button2up 'button2))) 'kom-mouse-null)
......@@ -3914,6 +3918,9 @@ i servern. Annars sparas det i din .emacs.")
(kom-highlight-text-body-doc . "\
Om detta r pslaget s visas inlggstexter med ett annorlunda utseende
n normal text.")
(kom-edit-hide-add-button-doc . "\
Om detta r pslaget s kommer knappen [Addera...] att visas efter
mottagare och tillggsinformation nr man skriver inlgg.")
;;
......@@ -4086,6 +4093,7 @@ i servern. Annars sparas det i din .emacs.")
(kom-highlight-first-line-tag . "Annorlunda bakgrundsfrg p frsta raden:")
(kom-highlight-dashed-lines-tag . "Annorlunda bakgrundsfrg fre och efter inlggstexten:")
(kom-highlight-text-body-tag . "Annorlunda bakgrundsfrg p inlggstexten:")
(kom-edit-hide-add-button-tag . "Visa Addera-knappen nr man skriver inlgg:")
)
)
......
......@@ -101,6 +101,12 @@ are in the list.")
;;; User flags
(def-kom-var kom-edit-hide-add-button nil
"*If non-nil, hide the add button shown after the headers when editing
a text."
server
)
(def-kom-var kom-highlight-text-body t
"*If t, use an alternate background color for texts in LysKOM.
If nil, do not use an alternate background. Other values are reserved
......
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