Commit 41167d17 authored by David Byers's avatar David Byers
Browse files

Lade till visning av PDF; skrev om unity-koden så den inte använder cl

parent 65dec441
2012-10-27 David Byers <>
* lyskom-rest.el (lyskom-unity-text): Rewrote without "some"
because the code did not require cl, which results in a
compilation warning. Note that cl is not loaded by default in Gnu
Emacs, and this is the only function that needed cl. Can't test,
because I don't have XEmacs.
(lyskom-format-pdf): New function to show PDF texts.
(lyskom-doc-view-end): New function.
(lyskom-doc-view-text): New function that displays PDF texts in
2012-10-01 Per Cederqvist <>
Fix user-area parsing.
......@@ -1549,6 +1549,11 @@ On since %#8s%#9s")
(reformat-rot13 . "rot13")
(pdf-no-show . "< PDF attachments are not supported. Emacs doc-view is required to display in new window. >")
(view-pdf . "%#1@< PDF attachments are not supported. > [View PDF in new window]")
(reformat-pdf . "pdf")
(doc-view-buffer-name . "Text %#1n: %#2s")
(need-library . "The \"%#1s\" package is required for this command.\n")
(calc-expression . "Expression: ")
......@@ -2374,21 +2374,25 @@ reappears."
(defvar latin-unity-cset-codesys-alist)
(defun lyskom-unity-text (start end &rest args)
(lambda (codesys)
(condition-case nil
(when (memq codesys latin-unity-iso-8859-1-aliases)
(setq codesys 'iso-8859-1))
(let ((gr (or (car (rassq codesys latin-unity-cset-codesys-alist))
(and codesys
(eq (lyskom-coding-system-type codesys) 'iso2022)
(lyskom-coding-system-property codesys 'charset-g1)))))
(when gr
(latin-unity-remap-region start (min (point-max) (1+ end))
gr nil t))))
(error nil)))
(lyskom-traverse codesys latin-unity-preferred-coding-system-list
(condition-case nil
(when (memq codesys latin-unity-iso-8859-1-aliases)
(setq codesys 'iso-8859-1))
(let ((gr (or (car (rassq codesys latin-unity-cset-codesys-alist))
(and codesys
(eq (lyskom-coding-system-type codesys) 'iso2022)
(lyskom-coding-system-property codesys 'charset-g1)))))
(when gr
(latin-unity-remap-region start (min (point-max) (1+ end))
gr nil t)))))
(error nil))
(defmacro lyskom-format-plaintext-fonts-body ()
"Internal macro for lyskom-format-plaintext-fonts"
......@@ -2488,6 +2492,12 @@ in lyskom-messages."
(defun lyskom-format-html-w3m (text text-stat)
(lyskom-format-html text text-stat 'w3m 'lyskom-w3m-region))
(defun lyskom-format-pdf (text text-stat)
(lyskom-signal-reformatted-text 'reformat-pdf)
(if (fboundp 'doc-view-mode)
(lyskom-format 'view-pdf (lyskom-default-button 'view-pdf (text-stat->text-no text-stat)))
(lyskom-format 'pdf-no-show)))
(defun lyskom-format-audio (text text-stat)
(lyskom-signal-reformatted-text 'reformat-audio)
(lyskom-format 'audio-no-show (lyskom-text-stat-content-type text text-stat)))
......@@ -2586,6 +2596,51 @@ in lyskom-messages."
(lyskom-button-transform-text (buffer-string) text-stat)
(buffer-substring (point-min) (1- (point-max))))))))
(defvar lyskom-doc-view-text-no)
(defvar lyskom-doc-view-temp-file)
(defun lyskom-doc-view-end ()
(when (boundp 'lyskom-doc-view-temp-file)
(condition-case nil
(delete-file lyskom-doc-view-temp-file)
(error nil))))
(defun lyskom-doc-view-text (text-no)
(let ((buf (lyskom-traverse buf (lyskom-buffers-of-category 'doc-view)
(set-buffer buf)
(when (and (boundp 'lyskom-doc-view-text-no)
(eq lyskom-doc-view-text-no text-no))
(lyskom-traverse-break buf))))))
(if buf
(lyskom-display-buffer buf)
(let* ((text (blocking-do 'get-text text-no))
(text-stat (blocking-do 'get-text-stat text-no))
(buf (lyskom-get-buffer-create 'doc-view "lyskom-view-document"))
(str (text->decoded-text-mass text text-stat))
(subj "")
(temp-file (make-temp-file "lyskom")))
(when (string-match "\n" str)
(setq subj (substring str 0 (match-beginning 0)))
(setq str (substring str (match-end 0))))
(set-buffer buf)
(insert str)
(set-buffer-file-coding-system 'raw-text)
(write-file (or buffer-file-name temp-file))
(rename-buffer (lyskom-format 'doc-view-buffer-name text-no subj))
(make-local-variable 'lyskom-doc-view-temp-file)
(make-local-variable 'lyskom-doc-view-text-no)
(setq lyskom-doc-view-temp-file temp-file)
(setq lyskom-doc-view-text-no text-no)
(add-hook 'kill-buffer-hook 'lyskom-doc-view-end nil t))
(lyskom-display-buffer buf)))))
(defun lyskom-get-holerith-list (text &optional no-coding)
"Assume that TEXT is a list of holerith strings. Return those strings."
(let (result tmp)
......@@ -1598,6 +1598,11 @@ Uppkopplad sedan %#8s%#9s")
(reformat-utf-8 . "var UTF-8")
(pdf-no-show . "< PDF-filer stds inte. Emacs doc-view krvs fr att visa i ny buffert. >")
(view-pdf . "%#1@< PDF-filer stds inte. > [Visa i ny buffert]")
(reformat-pdf . "pdf")
(doc-view-buffer-name . "Inlgg %#1n: %#2s")
(need-library . "Paketet \"%#1s\" behvs fr att utfra detta kommando.\n")
(calc-expression . "Uttryck: ")
......@@ -2029,7 +2034,7 @@ version %#3s av elispklienten, medan detta
(aux-mx-misc-name . "E-mailheader")
(aux-mx-allow-filter-name . "E-mail allow-filter")
(aux-mx-reject-forward-name . "E-mail reject-forward")
(aux-mx-allow-envelope-sender-regexp . "Tillten avsndare vid import:")
(aux-mx-allow-envelope-sender-regexp . "Tillten avsndare vid import")
(aux-notify-comments-name . "Meddela kommentarer")
(aux-faq-for-conf-name . "FAQ fr mte")
(aux-recommended-conf-name . "Mtesrekommendation")
......@@ -3402,6 +3402,11 @@ Values other than `nil' and strings are reserved for future use."
(set-buffer recpt-and-buffer)
(lambda (buffer argument text) (lyskom-doc-view-text argument))
"This variable defines valid button types in LysKOM. Each element is a
......@@ -4666,6 +4671,7 @@ Values other than those listed are reserved for future use."
("^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.
("^application/pdf" . lyskom-format-pdf)
("^x-kom/user-area" . lyskom-format-x-kom/user-area)
("^x-kom/ö\\." . lyskom-format-ö)
("^audio/" . lyskom-format-audio)
......@@ -1344,6 +1344,7 @@ Args: TEXT-STAT of the text being read."
(elt date 7)
(elt date 8))))))
;;; Local Variables:
;;; eval: (put 'lyskom-traverse 'lisp-indent-hook 2)
;;; end:
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