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

More fontification tweaks

Detailed changes:
> 	Better fontification code:
> 	* lyskom-rest.el: (lyskom-format-plaintext-fonts-body): New macro.
> 	For internal use only.
> 	(lyskom-format-plaintext-fonts): Don't use / as an italics
> 	delimiter.
>
parent 30f914a6
2004-02-29 David Byers <byers@lysator.liu.se> 2004-02-29 David Byers <byers@lysator.liu.se>
Better fontification code:
* lyskom-rest.el: (lyskom-format-plaintext-fonts-body): New macro.
For internal use only.
(lyskom-format-plaintext-fonts): Don't use / as an italics
delimiter.
Fix bug 1282: Fix bug 1282:
* services.el (initiate-query-read-texts): Call correct membership * services.el (initiate-query-read-texts): Call correct membership
parser. Use new names. parser. Use new names.
......
...@@ -1908,8 +1908,12 @@ Deferred insertions are not supported." ...@@ -1908,8 +1908,12 @@ Deferred insertions are not supported."
;; properties and the subject to the result list ;; properties and the subject to the result list
;; ;;
((= format-letter ?r) ((= format-letter ?r)
(setq result (cond ((stringp arg) (lyskom-button-transform-text arg)) (setq result (cond ((stringp arg)
((consp arg) (lyskom-button-transform-text (cdr arg) (car arg))) (lyskom-format-plaintext-fonts arg)
(lyskom-button-transform-text arg))
((consp arg)
(lyskom-format-plaintext-fonts (cdr arg))
(lyskom-button-transform-text (cdr arg) (car arg)))
(t (signal 'lyskom-internal-error (t (signal 'lyskom-internal-error
(list 'lyskom-format (list 'lyskom-format
": argument error (expected subject)" ": argument error (expected subject)"
...@@ -2168,20 +2172,38 @@ Deferred insertions are not supported." ...@@ -2168,20 +2172,38 @@ Deferred insertions are not supported."
gr nil t)))) gr nil t))))
(error nil)))) (error nil))))
(defun lyskom-format-plaintext-fonts (text)
(let ((start 0))
(while (string-match "\\(_[^ ^\n\r\t_]\\([^_^<>=%$\n]*[^ ^\n\r\t_]\\)?_\\)\\|\\(/[^ ^\n\r\t/]\\([^/^<>=%$\n]*[^ ^\n\r\t/]\\)?/\\)\\|\\(\\*[^ ^\n\r\t*]\\([^*^<>=%$\n]*[^ ^\n\r\t*]\\)?\\*\\)"
text start)
(add-text-properties (1+ (match-beginning 0))
(1- (match-end 0))
`(face ,(cond ((match-beginning 1) 'underline)
((match-beginning 3) 'italic)
((match-beginning 5) 'bold)))
text)
(setq start (1- (match-end 0))))))
(defmacro lyskom-format-plaintext-fonts-body ()
"Internal macro for lyskom-format-plaintext-fonts"
(let* ((re-x 0)
(re-1 "[^\]\}\) ^\n\r\t%s]")
(re-2 "[^^<>=%%$\r\n%s]")
(re-3 '(("_" . italic) ("*" . bold)))
(re (mapconcat (lambda (x)
(setq x (regexp-quote (car x)))
(format "\\(%s%s\\(%s*%s\\)?%s\\)"
x
(format re-1 x)
(format re-2 x)
(format re-1 x)
x))
re-3
"\\|")))
`(let ((start 0))
(while (string-match ,re text start)
(add-text-properties (1+ (match-beginning 0))
(1- (match-end 0))
(cond ,@(mapcar (lambda (el)
(prog1
`((match-beginning ,(+ 1 (* re-x 2)))
'(face ,(cdr (elt re-3 re-x))))
(setq re-x (1+ re-x))))
re-3))
text)
(setq start (1- (match-end 0)))))))
(defun lyskom-format-plaintext-fonts (text)
(lyskom-format-plaintext-fonts-body))
(defun lyskom-signal-reformatted-text (how) (defun lyskom-signal-reformatted-text (how)
......
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