all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* handwrite.el patch
@ 2006-11-07 13:55 Markus Triska
  2006-11-08  4:18 ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Triska @ 2006-11-07 13:55 UTC (permalink / raw)


[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 187 bytes --]


Attached patch for handwrite.el:

   * also process lines not ending with \n

   * replace some position-fiddling with different logic

   * improve performance

Best wishes! -- Markus


[-- Attachment #2: handwrite.patch --]
[-- Type: application/octet-stream, Size: 7515 bytes --]

Index: handwrite.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/play/handwrite.el,v
retrieving revision 1.12.6.6
diff -u -r1.12.6.6 handwrite.el
--- handwrite.el	8 Feb 2006 04:24:48 -0000	1.12.6.6
+++ handwrite.el	7 Nov 2006 13:27:07 -0000
@@ -155,6 +155,18 @@
        (buf-name (buffer-name) )
        (textp)
        (ps-buf-name)			;name of the PostScript buffer
+       (trans-table
+	'(("ÿ" . "264") ("á" . "207") ("à" . "210") ("â" . "211")
+	  ("ä" . "212") ("ã" . "213") ("å" . "214") ("é" . "216")
+	  ("è" . "217") ("ê" . "220") ("ë" . "221") ("í" . "222")
+	  ("ì" . "223") ("î" . "224") ("ï" . "225") ("ó" . "227")
+	  ("ò" . "230") ("ô" . "231") ("ö" . "232") ("õ" . "233")
+	  ("ú" . "234") ("ù" . "235") ("û" . "236") ("ü" . "237")
+	  ("ß" . "247") ("°" . "241") ("®" . "250") ("©" . "251")
+	  ("ij" . "264") ("ç" . "215") ("§" . "244") ("ñ" . "226")
+	  ("£" . "243")))
+       (escape-table '("\\\\" "(" ")")) ; \\ comes first to not work
+					; on inserted backslashes
        )
     (goto-char (point-min))		;start at beginning
     (setq handwrite-psindex (1+ handwrite-psindex))
@@ -178,155 +190,46 @@
     (switch-to-buffer cur-buf)
     (goto-char (point-min))		;start at beginning
     (save-excursion
-      ;;as long as we see a newline the document is not ended.
-      (while (re-search-forward "\n" nil t)
-	(previous-line 1)
-	(beginning-of-line)
-	(setq pmin (point))
-	(search-forward "\n" nil t)
-	(backward-char 1)
-	(copy-region-as-kill (point) pmin)
-	(forward-char 1)
+      (while (not (eobp))
+	(setq line (thing-at-point 'line))
+	(dolist (escape escape-table)
+	  (setq line (replace-regexp-in-string escape
+					       (concat "\\\\" escape) line)))
+	(dolist (trans trans-table)
+	  (setq line (replace-regexp-in-string (car trans)
+					       (concat "\\\\" (cdr trans))
+					       line)))
 	(switch-to-buffer ps-buf-name)
-	(yank)
+	(insert (replace-regexp-in-string "\n" "" line))
 	(message "write write write...")
-	(search-forward ")a" nil t)
-	(backward-char 2)
-	(setq lastp (point))
-	(beginning-of-line)
-	(search-forward "(" nil t)
-	(while (re-search-forward "[()\\]" lastp t)
-	  (save-excursion
-	    (setq lastp (+ lastp 1))
-	    (forward-char -1)
-	    (insert "\\")))
 	(setq ps-ypos (+ ps-ypos handwrite-linespace))
 	(end-of-line)
 	(insert "\n")
 	(setq lcount (+ lcount 1))
-	(cond ( (eq lcount handwrite-numlines)
-		(setq ipage (+ ipage 1))
-		(insert "0 0  m\n")
-		(insert "showpage exec Hwsave restore\n")
-		(insert "%%Page: " (number-to-string ipage) " "
-			(number-to-string ipage) "\n")
-		(insert "Hwjst\n")
-		(insert "/Hwsave save def\n")
-		(if handwrite-pagenumbering
-		    (insert "20 30 m\nxym(page "
-			    (number-to-string ipage) ")a\n"))
-		(setq ps-ypos 63)
-		(setq lcount 0)
-		))
-	(insert "44 "(number-to-string ps-ypos) " m\n")
+	(when (= lcount handwrite-numlines)
+	  (setq ipage (+ ipage 1))
+	  (insert "0 0  m\n")
+	  (insert "showpage exec Hwsave restore\n")
+	  (insert "%%Page: " (number-to-string ipage) " "
+		  (number-to-string ipage) "\n")
+	  (insert "Hwjst\n")
+	  (insert "/Hwsave save def\n")
+	  (if handwrite-pagenumbering
+	      (insert "20 30 m\nxym(page "
+		      (number-to-string ipage) ")a\n"))
+	  (setq ps-ypos 63)
+	  (setq lcount 0))
+	(insert "44 " (number-to-string ps-ypos) " m\n")
 	(insert "xym( )a")
 	(backward-char 3)
 	(switch-to-buffer cur-buf)
+	(forward-line 1)
 	))
     (switch-to-buffer ps-buf-name)
     (next-line 1)
     (insert "showpage exec Hwsave restore\n\n")
     (insert "%%Pages " (number-to-string ipage) " 0\n")
     (insert "%%EOF\n")
-    (goto-char textp)			;start where the inserted text begins
-    (while (search-forward "ÿ" nil t)
-      (replace-match "\\" nil t) (insert "264"))
-    (goto-char textp)
-    (while (search-forward "á" nil t)
-      (replace-match "\\" nil t) (insert "207"))
-    (goto-char textp)
-    (while (search-forward "à" nil t)
-      (replace-match "\\" nil t) (insert "210"))
-    (goto-char textp)
-    (while (search-forward "â" nil t)
-      (replace-match "\\" nil t) (insert "211"))
-    (goto-char textp)
-    (while (search-forward "ä" nil t)
-      (replace-match "\\" nil t) (insert "212"))
-    (goto-char textp)
-    (while (search-forward "ã" nil t)
-      (replace-match "\\" nil t) (insert "213"))
-    (goto-char textp)
-    (while (search-forward "å" nil t)
-      (replace-match "\\" nil t) (insert "214"))
-    (goto-char textp)
-    (while (search-forward "é" nil t)
-      (replace-match "\\" nil t) (insert "216"))
-    (goto-char textp)
-    (while (search-forward "è" nil t)
-      (replace-match "\\" nil t) (insert "217"))
-    (goto-char textp)
-    (while (search-forward "ê" nil t)
-      (replace-match "\\" nil t) (insert "220"))
-    (goto-char textp)
-    (while (search-forward "ë" nil t)
-      (replace-match "\\" nil t) (insert "221"))
-    (goto-char textp)
-    (while (search-forward "í" nil t)
-      (replace-match "\\" nil t) (insert "222"))
-    (goto-char textp)
-    (while (search-forward "ì" nil t)
-      (replace-match "\\" nil t) (insert "223"))
-    (goto-char textp)
-    (while (search-forward "î" nil t)
-      (replace-match "\\" nil t) (insert "224"))
-    (goto-char textp)
-    (while (search-forward "ï" nil t)
-      (replace-match "\\" nil t) (insert "225"))
-    (goto-char textp)
-    (while (search-forward "ó" nil t)
-      (replace-match "\\" nil t) (insert "227"))
-    (goto-char textp)
-    (while (search-forward "ò" nil t)
-      (replace-match "\\" nil t) (insert "230"))
-    (goto-char textp)
-    (while (search-forward "ô" nil t)
-      (replace-match "\\" nil t) (insert "231"))
-    (goto-char textp)
-    (while (search-forward "ö" nil t)
-      (replace-match "\\" nil t) (insert "232"))
-    (goto-char textp)
-    (while (search-forward "õ" nil t)
-      (replace-match "\\" nil t) (insert "233"))
-    (goto-char textp)
-    (while (search-forward "ú" nil t)
-      (replace-match "\\" nil t) (insert "234"))
-    (goto-char textp)
-    (while (search-forward "ù" nil t)
-      (replace-match "\\" nil t) (insert "235"))
-    (goto-char textp)
-    (while (search-forward "û" nil t)
-      (replace-match "\\" nil t) (insert "236"))
-    (goto-char textp)
-    (while (search-forward "ü" nil t)
-      (replace-match "\\" nil t) (insert "237"))
-    (goto-char textp)
-    (while (search-forward "ß" nil t)
-      (replace-match "\\" nil t) (insert "247"))
-    (goto-char textp)
-    (while (search-forward "°" nil t)
-      (replace-match "\\" nil t) (insert "241"))
-    (goto-char textp)
-    (while (search-forward "®" nil t)
-      (replace-match "\\" nil t) (insert "250"))
-    (goto-char textp)
-    (while (search-forward "©" nil t)
-      (replace-match "\\" nil t) (insert "251"))
-    (goto-char textp)
-    (while (search-forward "ij" nil t)
-      (replace-match "\\" nil t) (insert "264"))
-    (goto-char textp)
-    (while (search-forward "ç" nil t)
-      (replace-match "\\" nil t) (insert "215"))
-    (goto-char textp)
-    (while (search-forward "§" nil t)
-      (replace-match "\\" nil t) (insert "244"))
-    (goto-char textp)
-    (while (search-forward "ñ" nil t)
-      (replace-match "\\" nil t) (insert "226"))
-    (goto-char textp)
-    (while (search-forward "£" nil t)
-      (replace-match "\\" nil t) (insert "243"))
     ;;To avoid cumbersome code we simply ignore pagefeeds
     (goto-char textp)
     (while (search-forward "\f" nil t)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-07 13:55 handwrite.el patch Markus Triska
@ 2006-11-08  4:18 ` Richard Stallman
  2006-11-08 14:15   ` Markus Triska
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2006-11-08  4:18 UTC (permalink / raw)
  Cc: emacs-devel

I have not thoroughly checked your change, but it seems plausible.
Would you please send us a change log entry in the style of
lisp/ChangeLog?

I hope someone else will check it carefully.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-08  4:18 ` Richard Stallman
@ 2006-11-08 14:15   ` Markus Triska
  2006-11-09  0:54     ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Triska @ 2006-11-08 14:15 UTC (permalink / raw)
  Cc: Markus Triska, emacs-devel

Richard Stallman writes:

>  change log entry in the style of lisp/ChangeLog?

2006-11-08  Markus Triska  <triska@gmx.at>

	* handwrite.el (handwrite): also process lines not ending with
	newline; replace some position-fiddling with different logic;
	improve performance

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-08 14:15   ` Markus Triska
@ 2006-11-09  0:54     ` Richard Stallman
  2006-11-09  1:53       ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2006-11-09  0:54 UTC (permalink / raw)
  Cc: triska, emacs-devel

That change log entry looks good.  Would someone please check the code
change?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-09  0:54     ` Richard Stallman
@ 2006-11-09  1:53       ` Chong Yidong
  2006-11-09 23:27         ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Chong Yidong @ 2006-11-09  1:53 UTC (permalink / raw)
  Cc: Markus Triska, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> That change log entry looks good.  Would someone please check the code
> change?

I looked through it, but not thoroughly (I am not familiar with the
code).  It looks plausible.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-09  1:53       ` Chong Yidong
@ 2006-11-09 23:27         ` Richard Stallman
  2006-11-12 17:35           ` Chong Yidong
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2006-11-09 23:27 UTC (permalink / raw)
  Cc: triska, emacs-devel

    > That change log entry looks good.  Would someone please check the code
    > change?

    I looked through it, but not thoroughly (I am not familiar with the
    code).  It looks plausible.

Would you please install it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: handwrite.el patch
  2006-11-09 23:27         ` Richard Stallman
@ 2006-11-12 17:35           ` Chong Yidong
  0 siblings, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2006-11-12 17:35 UTC (permalink / raw)
  Cc: triska, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     > That change log entry looks good.  Would someone please check the code
>     > change?
>
>     I looked through it, but not thoroughly (I am not familiar with the
>     code).  It looks plausible.
>
> Would you please install it?

Done.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-11-12 17:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-07 13:55 handwrite.el patch Markus Triska
2006-11-08  4:18 ` Richard Stallman
2006-11-08 14:15   ` Markus Triska
2006-11-09  0:54     ` Richard Stallman
2006-11-09  1:53       ` Chong Yidong
2006-11-09 23:27         ` Richard Stallman
2006-11-12 17:35           ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.