Commit 4756d7ea authored by David Byers's avatar David Byers
Browse files

Fontify non-formatted HTML. Support w3m. Better randomization of ports for...

Fontify non-formatted HTML. Support w3m. Better randomization of ports for ssh. More robust formatting of text number.

Detailed changes:
> 2004-05-25  David Byers  <byers@lysator.liu.se>
>
> 	* lyskom-rest.el (lyskom-format-aux-help): Handle non-integer
> 	(i.e. floating point) numbers somewhat more gracefully.
>
> 2004-05-23  David Byers  <byers@lysator.liu.se>
>
> 	* lyskom-buttons.el (kom-button-click): Support w3m links.
>
> 	Support w3m; fontify urls when not rendering html:
> 	* lyskom-rest.el (lyskom-w3m-region): New function.
> 	(lyskom-w3-region): Use lyskom-render-html-region.
> 	(lyskom-render-html-region): New function.
> 	(lyskom-format-htmal-plaintext): New function.
> 	(lyskom-format-html): Made generic.
> 	(lyskom-format-html-w3): New function.
> 	(lyskom-format-html-w3m): New function.
>
> 	* vars.el.in (lyskom-format-special): When HTML formatting is off,
> 	fontify URLs and stuff.
>
> 	* lyskom-rest.el (w3-fetch): Don't call w3-finish-drawing. It used
> 	to be necessary, but now it causes the client to hang.
> 	(smiley-region): Support a stack of formatting functions.
>
> 2004-05-12  David Byers  <byers@lysator.liu.se>
>
> 	Fix bug 1320:
> 	* lyskom-rest.el (lyskom-is-loaded): Seed the randomizer.
>
parent f1538eba
2004-05-25 David Byers <byers@lysator.liu.se>
* lyskom-rest.el (lyskom-format-aux-help): Handle non-integer
(i.e. floating point) numbers somewhat more gracefully.
2004-05-23 David Byers <byers@lysator.liu.se>
* lyskom-buttons.el (kom-button-click): Support w3m links.
Support w3m; fontify urls when not rendering html:
* lyskom-rest.el (lyskom-w3m-region): New function.
(lyskom-w3-region): Use lyskom-render-html-region.
(lyskom-render-html-region): New function.
(lyskom-format-htmal-plaintext): New function.
(lyskom-format-html): Made generic.
(lyskom-format-html-w3): New function.
(lyskom-format-html-w3m): New function.
* vars.el.in (lyskom-format-special): When HTML formatting is off,
fontify URLs and stuff.
* lyskom-rest.el (w3-fetch): Don't call w3-finish-drawing. It used
to be necessary, but now it causes the client to hang.
(smiley-region): Support a stack of formatting functions.
2004-05-12 David Byers <byers@lysator.liu.se>
Fix bug 1320:
* lyskom-rest.el (lyskom-is-loaded): Seed the randomizer.
2004-05-04 David Byers <byers@lysator.liu.se>
* vars.el.in (kom-old-farts-text-prompt-strategy): Corrected
......
......@@ -43,6 +43,7 @@
(lyskom-external-function w3-popup-menu)
(lyskom-external-function Info-goto-node)
(lyskom-external-function term-char-mode)
(lyskom-external-function w3m)
(defun lyskom-add-button-action (type text func)
......@@ -124,6 +125,7 @@ this-command-keys."
(and parent (widget-get parent ':href))
(and widget (widget-get widget 'href))
(and parent (widget-get parent 'href))))
(w3m-url (and pos (get-text-property pos 'w3m-href-anchor)))
(type (and pos (get-text-property pos 'lyskom-button-type)))
(data (and type (assq type lyskom-button-actions)))
(hint (and pos (get-text-property pos 'lyskom-button-hint)))
......@@ -131,6 +133,8 @@ this-command-keys."
(and data (elt data 2)))))
(cond (href (require 'w3)
(w3-widget-button-click event))
(w3m-url (require 'w3m)
(w3m w3m-url))
((and do-default
(or (null pos)
(null (get-text-property pos 'lyskom-button-type))))
......
......@@ -1082,14 +1082,10 @@ back, and works even if from has the property."
(setq fn (get-text-property (car bounds) sym))
(remove-text-properties (car bounds) (cdr bounds) (list sym))
(condition-case val
(funcall (if (listp fn)
(car fn)
fn)
(funcall (if (listp fn) (car fn) fn)
(car bounds)
(cdr bounds)
(if (listp fn)
(cdr fn)
nil))
(if (listp fn) (cdr fn) nil))
(error (apply 'message "%S" val)))
(setq start next)
(setq bounds (lyskom-next-property-bounds
......@@ -1893,6 +1889,9 @@ Deferred insertions are not supported."
((= format-letter ?n)
(setq result
(cond ((integerp arg) (int-to-string arg))
((numberp arg)
(setq colon-flag t)
(format "%.0f" arg))
((lyskom-text-stat-p arg) (int-to-string
(text-stat->text-no arg)))
(t (signal 'lyskom-internal-error
......@@ -2131,7 +2130,14 @@ Deferred insertions are not supported."
(symbol-name (car el)))
content-type))
(lyskom-traverse-break el)))))))
(formatted (and fn (funcall fn text text-stat))))
(formatted (cond ((null fn) nil)
((listp fn)
(lyskom-traverse el fn
(let ((a (funcall el text text-stat)))
(when a (lyskom-traverse-break a)))))
((functionp fn)
(funcall fn text text-stat))
(t nil))))
(or formatted text)))
(defun lyskom-format-plaintext (text text-stat)
......@@ -2219,40 +2225,55 @@ in lyskom-messages."
(setq lyskom-last-text-format-flags (cons how lyskom-last-text-format-flags))))
(lyskom-with-external-functions (w3-fetch w3-region w3-finish-drawing)
(lyskom-with-external-functions (w3m-region)
(defun lyskom-w3m-region (start end &rest args)
(lyskom-render-html-region start end 'w3m-region)))
(lyskom-with-external-functions (w3-region)
(defun lyskom-w3-region (start end &rest args)
(unwind-protect
(condition-case var
(save-restriction
(let ((buffer-read-only nil))
(setq start (set-marker (make-marker) start))
(setq end (set-marker (make-marker) end))
(narrow-to-region start end)
(when kom-w3-simplify-body
(save-excursion
(let ((case-fold-search t))
(goto-char start)
(while (re-search-forward "<body[^>]*>" end t)
(replace-match "<body>")))))
(w3-region start end)
(w3-finish-drawing)
(add-text-properties (point-min) (point-max) '(end-closed nil))))
(error (lyskom-ignore var))))))
(lyskom-render-html-region start end 'w3-region)))
(defun lyskom-render-html-region (start end fun)
(unwind-protect
(condition-case var
(save-restriction
(let ((buffer-read-only nil))
(setq start (set-marker (make-marker) start))
(setq end (set-marker (make-marker) end))
(narrow-to-region start end)
(when kom-w3-simplify-body
(save-excursion
(let ((case-fold-search t))
(goto-char start)
(while (re-search-forward "<body[^>]*>" end t)
(replace-match "<body>")))))
(funcall fun start end)
(add-text-properties (point-min) (point-max) '(end-closed nil))))
(error (lyskom-ignore var)))))
(defun lyskom-format-html (text text-stat)
(defun lyskom-format-html-plaintext (text text-stat)
(lyskom-button-transform-text text-stat))
(defun lyskom-format-html (text text-stat package function)
;; Find settings for this author
(let ((author-setting (and text-stat (or (assq (text-stat->author text-stat)
kom-format-html-authors)
(assq t kom-format-html-authors)))))
(when (and (cdr author-setting)
(condition-case e (progn (require 'w3) t) (error nil)))
(add-text-properties 0 (length text) '(special-insert lyskom-w3-region) text)
(condition-case e (progn (require package) t) (error nil)))
(add-text-properties 0 (length text) `(special-insert ,function) text)
(lyskom-signal-reformatted-text 'reformat-html)
(if (string-match "^html:" text)
(substring text 5)
text))))
(defun lyskom-format-html-w3 (text text-stat)
(lyskom-format-html text text-stat 'w3 'lyskom-w3-region))
(defun lyskom-format-html-w3m (text text-stat)
(lyskom-format-html text text-stat 'w3m 'lyskom-w3m-region))
(defun lyskom-format-enriched (text text-stat)
......@@ -4333,6 +4354,10 @@ One parameter - the prompt string."
(lyskom-set-queue-priority 'modeline 6)
(lyskom-set-queue-priority 'async 3)
(lyskom-set-queue-priority 'prefetch 0)
;; Seed the randomizer
(random t)
(run-hooks 'lyskom-after-load-hook)
(run-hooks 'kom-after-load-hook)
(setq lyskom-is-loaded t))
......
......@@ -4238,15 +4238,15 @@ Values other than those listed are reserved for future use."
server)
(def-kom-var lyskom-format-special
'(("html" . lyskom-format-html)
'(("html" . (lyskom-format-html-w3m lyskom-format-html-w3 lyskom-format-html-plaintext))
("enriched" . lyskom-format-enriched)
("text/html" . lyskom-format-html)
("text/enriched" . lyskom-format-enriched)
("^text/html" . (lyskom-format-html-w3m lyskom-format-html-w3 lyskom-format-html-plaintext))
("^text/enriched" . lyskom-format-enriched)
("^text/" . lyskom-format-plaintext)
("x-kom/text" . lyskom-format-plaintext) ;Archaic alias for text/x-kom-basic.
("x-kom/basic" . lyskom-format-plaintext) ;Archaic alias for text/x-kom-basic.
("x-kom/user-area" . lyskom-format-x-kom/user-area)
("x-kom/ö\\." . lyskom-format-ö))
("^x-kom/text" . lyskom-format-plaintext) ;Archaic alias for text/x-kom-basic.
("^x-kom/basic" . lyskom-format-plaintext) ;Archaic alias for text/x-kom-basic.
("^x-kom/user-area" . lyskom-format-x-kom/user-area)
("^x-kom/ö\\." . lyskom-format-ö))
"AList of (FORMAT . FUNCTION) specifying functions that format texts
of that type. FORMAT is a symbol and FUNCTION is a function taking one
argument and returning a formatted string.")
......
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