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

Fixade ombrytning av inlägg.

parent bf5825b5
Sat Jul 12 12:46:46 1997 David Byers <davby@ida.liu.se>
* english-strings.el,swedish-strings.el (lyskom-custom-strings):
Lade till dokumentation och tag fr kom-autowrap.
* edit-text.el: Zappa lite varningar.
* option-edit.el: Dito.
* menus.el: Dito.
* lyskom-buttons.el: Dito.
* commands1.el (kom-display-time): Bind
lyskom-last-text-format-flags.
* remote-control.el (lyskom-remote-set-message): Dito.
* ansaphone.el (kom-change-auto-reply): Dito.
* async.el (lyskom-format-as-personal-message): Dito.
* commands2.el (lyskom-send-message): Dito.
* view-text.el (lyskom-print-text): Skriv ut om texten r
omformatterad.
(lyskom-deferred-insert-footer): Dito.
(lyskom-view-text): Bind lyskom-last-text-format-flags.
* english-strings.el, swedish-strings.el (lyskom-message): Lade
till reformat-*
* lyskom-rest.el (lyskom-fill-message): Ny funktion.
(lyskom-format-text-body): Anropa lyskom-fill-message.
(lyskom-signal-reformatted-text): Ny funktion.
* vars.el.in (kom-autowrap): Ny variabel.
(lyskom-line-start-chars): Ny variabel.
* review.el (kom-review-noconversion): Sl av massor av
formattering.
* swedish-strings.el (lyskom-sv-edit-mode-map): Bind [] mfl ven
i XEmacs, men bind *dessutom* aring och liknande.
(lyskom-sv-mode-map): Dito.
Fri Jul 11 09:17:28 1997 David Byers <davby@ida.liu.se> Fri Jul 11 09:17:28 1997 David Byers <davby@ida.liu.se>
* compatibility.el: Tog bort popup-menu eftersom vissa Gnu Emacs * compatibility.el: Tog bort popup-menu eftersom vissa Gnu Emacs
......
...@@ -58,7 +58,8 @@ ...@@ -58,7 +58,8 @@
(interactive) (interactive)
(let ((message (or message (let ((message (or message
(read-from-minibuffer (read-from-minibuffer
(lyskom-get-string 'ansaphone-new-message))))) (lyskom-get-string 'ansaphone-new-message))))
(lyskom-last-text-format-flags nil))
(setq kom-ansaphone-default-reply message) (setq kom-ansaphone-default-reply message)
(lyskom-format-insert (lyskom-get-string 'ansaphone-message) (lyskom-format-insert (lyskom-get-string 'ansaphone-message)
kom-ansaphone-default-reply))) kom-ansaphone-default-reply)))
......
...@@ -343,7 +343,7 @@ MESSAGE is a string containing the message. ...@@ -343,7 +343,7 @@ MESSAGE is a string containing the message.
WHEN, if given, is the time when the message arrived. It must be of the same WHEN, if given, is the time when the message arrived. It must be of the same
format at (current-time-string) format at (current-time-string)
Non-nil NOBEEP means don't beep." Non-nil NOBEEP means don't beep."
(progn (let ((lyskom-last-text-format-flags nil))
(if (null when) (if (null when)
(setq when (current-time-string))) (setq when (current-time-string)))
(if (not (string= (substring when 0 10) (if (not (string= (substring when 0 10)
......
...@@ -1493,7 +1493,8 @@ If MARK-NO == 0, review all marked texts." ...@@ -1493,7 +1493,8 @@ If MARK-NO == 0, review all marked texts."
(def-kom-command kom-display-time () (def-kom-command kom-display-time ()
"Ask server about time and date." "Ask server about time and date."
(interactive) (interactive)
(let ((time (blocking-do 'get-time))) (let ((time (blocking-do 'get-time))
(lyskom-last-text-format-flags nil))
(lyskom-format-insert 'time-is (lyskom-format-insert 'time-is
(lyskom-format-time time) (lyskom-format-time time)
;; Kult: ;; Kult:
......
...@@ -516,7 +516,8 @@ means send the message to everybody. MESSAGE is the message to ...@@ -516,7 +516,8 @@ means send the message to everybody. MESSAGE is the message to
send. If DONTSHOW is non-nil, don't display the sent message." send. If DONTSHOW is non-nil, don't display the sent message."
(let* ((lyskom-message-string nil) (let* ((lyskom-message-string nil)
(reply nil) (reply nil)
(lyskom-message-recipient nil)) (lyskom-message-recipient nil)
(lyskom-last-text-format-flags nil))
(add-hook 'minibuffer-setup-hook (add-hook 'minibuffer-setup-hook
'lyskom-send-message-minibuffer-setup-hook) 'lyskom-send-message-minibuffer-setup-hook)
......
...@@ -385,28 +385,10 @@ Commands: ...@@ -385,28 +385,10 @@ Commands:
(lyskom-message "%s" (lyskom-get-string (car (cdr err))))))) (lyskom-message "%s" (lyskom-get-string (car (cdr err)))))))
(eval-when-compile (defvar ispell-dictionary nil)) (eval-when-compile (defvar ispell-dictionary nil))
(eval-when-compile (defvar ispell-message-text-end nil))
(eval-when-compile (defvar ispell-message-start-skip nil))
(eval-when-compile (defvar ispell-message-end-skip nil))
(defun lyskom-ispell-text ()
"Check spelling of the text body.
kom-ispell-dictionary is the dictionary to use to check spelling."
(let ((start
(save-excursion
(goto-char (point-min))
(search-forward (substitute-command-keys
(lyskom-get-string 'header-separator)))
(forward-line 1)
(beginning-of-line)
(point))))
(let ((ispell-dictionary kom-ispell-dictionary)
(new-ispell (or (not (boundp 'ispell-dictionary))
(not (string= kom-ispell-dictionary
ispell-dictionary)))))
(if new-ispell
(ispell-kill-ispell t))
(prog1
(ispell-region start (point-max))
(if new-ispell
(ispell-kill-ispell t))))))
(defun lyskom-ispell-text () (defun lyskom-ispell-text ()
"Check spelling of the text body. "Check spelling of the text body.
......
...@@ -1013,6 +1013,10 @@ On since %#8s%#9s") ...@@ -1013,6 +1013,10 @@ On since %#8s%#9s")
(send-formatted . "Send as formatted text? ") (send-formatted . "Send as formatted text? ")
(changing-language-to . "Changing to %#1s.\n") (changing-language-to . "Changing to %#1s.\n")
(language-not-loaded . "%#1s is unavailable.\n") (language-not-loaded . "%#1s is unavailable.\n")
(reformat-html . "(HTML)")
(reformat-enriched . "(Enriched)")
(reformat-filled . "(Filled)")
)) ))
...@@ -1938,6 +1942,11 @@ Lists etc. : [INS] Add a line [DEL] Remove a line [*] Modify") ...@@ -1938,6 +1942,11 @@ Lists etc. : [INS] Add a line [DEL] Remove a line [*] Modify")
Most people have this turned on.") Most people have this turned on.")
(kom-autowrap-doc . "\
With this setting turned on, LysKOM will attempt to fill any paragraphs
containing lines that are wider than the screen. Paragraphs that appear
to have been preformatted by the author are exempt from this treatment.")
(kom-show-author-at-end-doc . "\ (kom-show-author-at-end-doc . "\
When this is turned on the name of the author will be shown at the end When this is turned on the name of the author will be shown at the end
of the article text. The name is also shown before the text as usual. of the article text. The name is also shown before the text as usual.
...@@ -2228,6 +2237,8 @@ Lists etc. : [INS] Add a line [DEL] Remove a line [*] Modify") ...@@ -2228,6 +2237,8 @@ Lists etc. : [INS] Add a line [DEL] Remove a line [*] Modify")
"Default priority for new memberships: ") "Default priority for new memberships: ")
(kom-dashed-lines-tag . (kom-dashed-lines-tag .
"Dashed lines around the article body: ") "Dashed lines around the article body: ")
(kom-autowrap-tag .
"Fill wide paragraphs before displaying: ")
(kom-show-author-at-end-tag . (kom-show-author-at-end-tag .
"Show the name of the author after the body: ") "Show the name of the author after the body: ")
......
...@@ -650,6 +650,8 @@ This is a LysKOM button action." ...@@ -650,6 +650,8 @@ This is a LysKOM button action."
(elt manager 2)))) (elt manager 2))))
(eval-when-compile (defvar browse-url-browser-function nil))
(defun lyskom-view-url-browse-url (url manager) (defun lyskom-view-url-browse-url (url manager)
(require 'browse-url) (require 'browse-url)
(funcall browse-url-browser-function url)) (funcall browse-url-browser-function url))
......
...@@ -1370,8 +1370,16 @@ Note that it is not allowed to use deferred insertions in the text." ...@@ -1370,8 +1370,16 @@ Note that it is not allowed to use deferred insertions in the text."
(formatted (and fn (funcall fn text)))) (formatted (and fn (funcall fn text))))
(cond (formatted formatted) (cond (formatted formatted)
(kom-text-properties (lyskom-button-transform-text text)) (kom-text-properties
(t text)))) (lyskom-button-transform-text
(lyskom-fill-message text)))
(t (lyskom-fill-message text)))))
(defun lyskom-signal-reformatted-text (how)
"Signal that the last text was reformatted HOW, which should be a string
in lyskom-messages."
(setq lyskom-last-text-format-flags how))
(defun lyskom-w3-region (start end) (defun lyskom-w3-region (start end)
(w3-region start end) (w3-region start end)
...@@ -1380,6 +1388,7 @@ Note that it is not allowed to use deferred insertions in the text." ...@@ -1380,6 +1388,7 @@ Note that it is not allowed to use deferred insertions in the text."
(defun lyskom-format-html (text) (defun lyskom-format-html (text)
(condition-case e (require 'w3) (error nil)) (condition-case e (require 'w3) (error nil))
(add-text-properties 0 (length text) '(special-insert lyskom-w3-region) text) (add-text-properties 0 (length text) '(special-insert lyskom-w3-region) text)
(lyskom-signal-reformatted-text 'reformat-html)
(substring text 5)) (substring text 5))
;;;(defun lyskom-format-html (text) ;;;(defun lyskom-format-html (text)
...@@ -1417,12 +1426,163 @@ Note that it is not allowed to use deferred insertions in the text." ...@@ -1417,12 +1426,163 @@ Note that it is not allowed to use deferred insertions in the text."
(set-buffer tmpbuf) (set-buffer tmpbuf)
(insert (substring text 10)) (insert (substring text 10))
(format-decode-buffer) (format-decode-buffer)
(lyskom-signal-reformatted-text 'reformat-enriched)
(lyskom-button-transform-text (buffer-string)) (lyskom-button-transform-text (buffer-string))
;; (substring (buffer-string) 0 -1) ; Remove the \n ;; (substring (buffer-string) 0 -1) ; Remove the \n
) )
(kill-buffer tmpbuf))))) (kill-buffer tmpbuf)))))
;;; ============================================================
;;; lyskom-fill-message
;;; Author: David Byers
;;;
;;; Wrap the lines of a message with long lines so they're a little easier
;;; to read. Try to ignore what looks like preformatted text.
;;;
;;; A paragraph consisting only of short lines is not wrapped
;;; A paragraph with at least one line that starts with some odd
;;; character is not wrapped. Whitespace is considered odd if
;;; if occurs on any line but the first.
;;; A paragraph is not wrapped if it is more than one line long and the
;;; difference between line lengths is constant.
;;;
(defun lyskom-fill-message (text)
"Try to reformat a message."
(if (null kom-autowrap)
text
(save-excursion
(set-buffer (lyskom-get-buffer-create 'lyskom-text " lyskom-text" t))
(erase-buffer)
(insert text)
(goto-char (point-min))
(let ((start (point))
(in-paragraph nil)
(wrap-paragraph 'maybe)
(length-difference nil)
(constant-length nil)
(current-line-length nil)
(last-line-length nil)
(paragraph-length 0)
(fill-column (1- (window-width))))
;;
;; Scan each line
;;
(while (not (eobp))
(setq current-line-length (lyskom-fill-message-line-length))
;;
;; Do some work on checking for constant differences
;;
(cond ((null length-difference)
(when (and current-line-length last-line-length)
(setq length-difference (- current-line-length
last-line-length))))
((eq constant-length 'maybe-not)
(setq constant-length nil))
(constant-length
(unless (= (- current-line-length last-line-length)
length-difference)
(setq constant-length 'maybe-not))))
(cond
;;
;; An empty line signifies a new paragraph. If we were scanning
;; a paragraph and it was to be filled, fill it.
;;
((looking-at "^\\s-*$")
(when (and in-paragraph
(eq wrap-paragraph t)
(or (eq paragraph-length 1)
(null constant-length)))
(fill-region start (match-beginning 0)
nil t)
(lyskom-signal-reformatted-text 'reformat-filled))
(setq start (match-end 0)
in-paragraph nil
wrap-paragraph 'maybe))
;;
;; Not in a paragraph, but here comes some text. Let's start
;; a paragraph, shall we?
;;
((and (not in-paragraph)
(looking-at "\\s-*\\(\\S-\\)"))
(setq in-paragraph t
paragraph-length 0
constant-length t
length-difference nil
last-line-length nil
start (match-beginning 0))
(cond ((not (aref lyskom-line-start-chars
(char-to-int
(char-after (match-beginning 1)))))
(setq wrap-paragraph nil))
((> current-line-length fill-column)
(setq wrap-paragraph t))
(t (setq wrap-paragraph 'maybe))))
;;
;; Scanning a paragraph, we see a line that starts with something
;; not usually part of plain text. Don't wrap the paragraph.
;;
((and in-paragraph
(not (aref lyskom-line-start-chars (char-to-int
(char-after (point))))))
(setq wrap-paragraph nil))
;;
;; We're in a paragraph, the line looks OK, but is long. That
;; means we should probably be filling the paragraph later
;;
((and in-paragraph
wrap-paragraph
(> current-line-length fill-column))
(setq wrap-paragraph t)))
(setq last-line-length current-line-length)
(end-of-line)
(setq paragraph-length (1+ paragraph-length))
(unless (eobp)
(forward-line 1)
(beginning-of-line)))
;;
;; We've seen the end of buffer. Fill any unfilled junk.
;;
(when (and in-paragraph
(eq wrap-paragraph t)
(or (eq paragraph-length 1)
(null constant-length)))
(fill-region start (point) nil t)
(lyskom-signal-reformatted-text 'reformat-filled)))
;;
;; Kill off unwanted whitespace at the end of the message
;;
(let ((tmp (buffer-string)))
(if (string-match "[ \t\n]+\\'" tmp)
(substring tmp 0 (match-beginning 0))
tmp)))))
(defun lyskom-fill-message-line-length ()
(- (save-excursion (end-of-line) (point)) (point)))
;;; ============================================================ ;;; ============================================================
;;; Beeping and feeping ;;; Beeping and feeping
;;; Faces and colors ;;; Faces and colors
......
...@@ -227,6 +227,8 @@ ...@@ -227,6 +227,8 @@
(setq lyskom-current-menu-category (list menu-category)) (setq lyskom-current-menu-category (list menu-category))
(add-to-list 'lyskom-current-menu-category menu-category))) (add-to-list 'lyskom-current-menu-category menu-category)))
(eval-when-compile (defvar default-menubar nil))
(defun lyskom-set-menus-xemacs (menu-category) (defun lyskom-set-menus-xemacs (menu-category)
"Update the menus" "Update the menus"
(make-local-variable 'current-menubar) (make-local-variable 'current-menubar)
......
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
[kom-membership-default-priority] [kom-membership-default-priority]
"\n" "\n"
[kom-print-number-of-unread-on-entrance] [kom-print-number-of-unread-on-entrance]
[kom-autowrap]
[kom-dashed-lines] [kom-dashed-lines]
[kom-show-author-at-end] [kom-show-author-at-end]
...@@ -193,6 +194,8 @@ customize buffer but do not save them to the server." ...@@ -193,6 +194,8 @@ customize buffer but do not save them to the server."
(widget-value (cdr (car tmp)))) (widget-value (cdr (car tmp))))
(setq tmp (cdr tmp)))))) (setq tmp (cdr tmp))))))
(eval-when-compile (defvar save-options-init-file nil))
(defun lyskom-customize-send () (defun lyskom-customize-send ()
"Save variables to the server" "Save variables to the server"
(save-excursion (save-excursion
...@@ -403,6 +406,7 @@ customize buffer but do not save them to the server." ...@@ -403,6 +406,7 @@ customize buffer but do not save them to the server."
:size 0) :size 0)
(const (ask nil))))) (const (ask nil)))))
(kom-reading-puts-comments-in-pointers-last (toggle (before after))) (kom-reading-puts-comments-in-pointers-last (toggle (before after)))
(kom-autowrap (toggle (on off)))
(kom-dashed-lines (toggle (on off))) (kom-dashed-lines (toggle (on off)))
(kom-show-author-at-end (toggle (on off))) (kom-show-author-at-end (toggle (on off)))
(kom-print-number-of-unread-on-entrance (toggle (yes no))) (kom-print-number-of-unread-on-entrance (toggle (yes no)))
......
...@@ -223,7 +223,7 @@ Handler to implement remote control of the ansaphone." ...@@ -223,7 +223,7 @@ Handler to implement remote control of the ansaphone."
(defun lyskom-remote-set-message (arg sender recipient text) (defun lyskom-remote-set-message (arg sender recipient text)
(if arg (if arg
(progn (let ((lyskom-last-text-format-flags nil))
(setq kom-ansaphone-default-reply arg) (setq kom-ansaphone-default-reply arg)
(setq lyskom-ansaphone-when-set (current-time-string)) (setq lyskom-ansaphone-when-set (current-time-string))
(lyskom-ansaphone-send-message sender (lyskom-ansaphone-send-message sender
......
...@@ -1112,7 +1112,9 @@ text is shown and a REVIEW list is built to shown the other ones." ...@@ -1112,7 +1112,9 @@ text is shown and a REVIEW list is built to shown the other ones."
(t (t
(signal 'lyskom-internal-error '(kom-review-noconversion)))))) (signal 'lyskom-internal-error '(kom-review-noconversion))))))
(lyskom-start-of-command 'kom-review-noconversion) (lyskom-start-of-command 'kom-review-noconversion)
(let ((kom-emacs-knows-iso-8859-1 t)) (let ((kom-emacs-knows-iso-8859-1 t)
(lyskom-format-special nil)
(kom-autowrap nil))
(ignore kom-emacs-knows-iso-8859-1) (ignore kom-emacs-knows-iso-8859-1)
(lyskom-view-text text-no)) (lyskom-view-text text-no))
(lyskom-end-of-command)) (lyskom-end-of-command))
......
No preview for this file type
...@@ -471,6 +471,10 @@ various LysKOM elements.") ...@@ -471,6 +471,10 @@ various LysKOM elements.")
(def-kom-var kom-use-button-hints t (def-kom-var kom-use-button-hints t
"*Non-nil means use button hints for overriding default actions.") "*Non-nil means use button hints for overriding default actions.")
(def-kom-var kom-autowrap t
"*Non-nil means auto wrap articles with discretion"
server)
;;; ;;;
;;; lyskom-button-actions has been moved to swedish-strings.el on account ;;; lyskom-button-actions has been moved to swedish-strings.el on account
...@@ -1626,6 +1630,25 @@ texts that is to be sent to the server.") ...@@ -1626,6 +1630,25 @@ texts that is to be sent to the server.")
"Saved value of buffer-read-only when in slow mode." "Saved value of buffer-read-only when in slow mode."
local) local)
(def-kom-var lyskom-line-start-chars
[nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil t
nil t nil t t t t t t nil t t t t t t t t t t t t t nil nil t nil nil
nil nil t t t t t t t t t t t t t t t t t t t t t t t t t t t t t nil
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil t nil
t t t nil t nil t t t t t t nil nil t t t nil t t nil nil t t t t t t
t t t t t t t t t t t t t t t t t t t t t t t t nil t t t t t t t t t
t t t t t t t t t t t t t t t t t t t t t t nil t t t t t t t t]
"Vector defining which ISO-8859-1 characters can be expected to start
lines of text.")
(def-kom-var lyskom-last-text-format-flags nil
"List of flags specifying how the last text was reformatted. This variable
should be dynamically bound whenever it needs to be used.")
;;; ====================================================================== ;;; ======================================================================
;;; Event hooks ;;; Event hooks
;;; ;;;
......
...@@ -57,7 +57,8 @@ Note that this function must not be called asynchronously." ...@@ -57,7 +57,8 @@ Note that this function must not be called asynchronously."
(lyskom-filter-text-p text-no))) (lyskom-filter-text-p text-no)))
(start nil) (start nil)
(end nil) (end nil)
(todo nil)) (todo nil)
(lyskom-last-text-format-flags nil))
(cond ((eq filter 'skip-text) (lyskom-filter-prompt text-no 'filter-text) (cond ((eq filter 'skip-text) (lyskom-filter-prompt text-no 'filter-text)
(setq todo 'next-text) (setq todo 'next-text)
(lyskom-mark-as-read (blocking-do 'get-text-stat text-no)) (lyskom-mark-as-read (blocking-do 'get-text-stat text-no))
...@@ -409,11 +410,15 @@ the user is a member of. Uses blocking-do. Returns t if TEXT-STAT is nil." ...@@ -409,11 +410,15 @@ the user is a member of. Uses blocking-do. Returns t if TEXT-STAT is nil."
(dashes (if (> 42 (length name)) (dashes (if (> 42 (length name))
(make-string (- 42 (length name)) ?-) (make-string (- 42 (length name)) ?-)
"")) ""))
(text (lyskom-format "/%[%#3@%#1P%]/%#2s" (text (lyskom-format "/%[%#3@%#1P%]/%#2s%#4s"
(or conf-stat name) (or conf-stat name)
dashes dashes
(text-properties-at (text-properties-at
(defer-info->pos defer-info))))) (defer-info->pos defer-info))
(if (defer-info->data defer-info)
(lyskom-get-string
(defer-info->data defer-info))
""))))
(lyskom-replace-deferred defer-info text))) (lyskom-replace-deferred defer-info text)))
(defun lyskom-print-text (text-stat text mark-as-read text-no) (defun lyskom-print-text (text-stat text mark-as-read text-no)
...@@ -463,7 +468,12 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO." ...@@ -463,7 +468,12 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO."
(cond (kom-dashed-lines (cond (kom-dashed-lines
(lyskom-format-insert "\n(%#1n) " (text->text-no text)) (lyskom-format-insert "\n(%#1n) " (text->text-no text))
(if (not kom-show-author-at-end) (if (not kom-show-author-at-end)
(lyskom-insert "-----------------------------------\n") (progn
(lyskom-format-insert
"-----------------------------------%#1s\n"
(if lyskom-last-text-format-flags
(lyskom-get-string lyskom-last-text-format-flags)
"")))
(if kom-deferred-printing (if kom-deferred-printing
(progn (progn
(lyskom-format-insert "%#1s\n" lyskom-defer-indicator) (lyskom-format-insert "%#1s\n" lyskom-defer-indicator)
...@@ -478,7 +488,8 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO." ...@@ -478,7 +488,8 @@ Args: TEXT-STAT TEXT MARK-AS-READ TEXT-NO."
(length lyskom-defer-indicator) (length lyskom-defer-indicator)
1)) 1))