all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Slight improvement to WoMan tbl handling
@ 2010-02-17 14:55 Michael Vehrs
  2010-02-19  0:27 ` Glenn Morris
  2010-02-19 13:20 ` Andreas Schwab
  0 siblings, 2 replies; 12+ messages in thread
From: Michael Vehrs @ 2010-02-17 14:55 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]


-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

[-- Attachment #2: woman.diff --]
[-- Type: text/x-diff, Size: 4288 bytes --]

--- woman.el.orig	2010-02-15 14:37:45.000000000 +0100
+++ woman.el	2010-02-17 15:47:29.000000000 +0100
@@ -3774,7 +3774,9 @@
                              (setq fn 'woman2-format-paragraphs))))
                ()
              ;; Find next control line:
-             (set-marker to (woman-find-next-control-line))
+             (if (equal request "TS")
+                 (set-marker to (woman-find-next-control-line "TE"))
+               (set-marker to (woman-find-next-control-line)))
              ;; Call the appropriate function:
              (funcall fn to)))
       (if (not (eobp))			; This should not happen, but ...
@@ -3785,12 +3787,13 @@
       (fset 'insert-and-inherit insert-and-inherit)
       (set-marker to nil))))
 
-(defun woman-find-next-control-line ()
+(defun woman-find-next-control-line (&optional pat)
   "Find and return start of next control line."
 ;  (let ((to (save-excursion
 ;	      (re-search-forward "^\\." nil t))))
 ;    (if to (1- to) (point-max)))
-  (let (to)
+  (let ((pattern (concat "\\(\\\\c\\)?\n[.']" (if pat pat "")))
+        to)
     (save-excursion
       ;; Must handle
       ;; ...\c
@@ -3799,12 +3802,12 @@
       ;; BEWARE THAT THIS CODE MAY BE UNRELIABLE!!!!!
       (while
 	  (and
-	   (setq to (re-search-forward "\\(\\\\c\\)?\n[.']" nil t))
+	   (setq to (re-search-forward pattern nil t))
 	   (match-beginning 1)
 	   (looking-at "br"))
 	(goto-char (match-beginning 0))
 	(woman-delete-line 2)))
-    (if to (1- to) (point-max))))
+    (if to (- to (+ 1 (length pat))) (point-max))))
 
 (defun woman2-PD (to)
   ".PD d -- Set the interparagraph distance to d.
@@ -4560,7 +4563,6 @@
   ".TS -- Start of table code for the tbl processor.
 Format paragraphs upto TO."
   ;; This is a preliminary hack that seems to suffice for lilo.8.
-  (woman-delete-line 1)			; ignore any arguments
   (when woman-emulate-tbl
     ;; Assumes column separator is \t and intercolumn spacing is 3.
     ;; The first line may optionally be a list of options terminated by
@@ -4572,6 +4574,21 @@
     (woman-delete-line 1)
     ;; For each column, find its width and align it:
     (let ((start (point)) (col 1))
+      ;; change T{ T} to tabs
+      (while (search-forward "T{\n" to t)
+        (replace-match "")
+        (catch 'end
+          (while (search-forward "\n" to t)
+            (replace-match " ")
+            (if (looking-at "T}")
+                (progn
+                  (delete-char 2)
+                  (throw 'end t))))))
+      (goto-char start)
+      ;; strip space and headers
+      (while (re-search-forward "^\\.TH\\|\\.sp" to t)
+        (woman-delete-whole-line))
+      (goto-char start)
       (while (prog1 (search-forward "\t" to t) (goto-char start))
 	;; Find current column width:
 	(while (< (point) to)
@@ -4587,7 +4604,24 @@
 	    (delete-char -1)
 	    (insert-char ?\  (- col (current-column))))
 	  (forward-line))
-	(goto-char start))))
+        (goto-char start))
+      ;; find maximum width
+      (let ((max-col 0))
+        (while (search-forward "\n" to t)
+          (backward-char)
+          (if (> (current-column) max-col)
+              (setq max-col (current-column)))
+          (forward-char))          
+        (goto-char start)
+        ;; break lines if they are too long
+        (when (and (> max-col woman-fill-column)
+                   (> woman-fill-column col))
+          (setq max-col woman-fill-column)
+          (woman-break-table col to)
+          (goto-char start))          
+        (while (re-search-forward "^_$" to t)
+          (replace-match (make-string max-col ?_)))
+        (goto-char start))))
   ;; Format table with no filling or adjusting (cf. woman2-nf):
   (setq woman-nofill t)
   (woman2-format-paragraphs to))
@@ -4596,6 +4630,18 @@
   ;; ".TE -- End of table code for the tbl processor."
   ;; Turn filling and adjusting back on.
 
+(defun woman-break-table (start-column to)
+  (while (< (point) to)
+    (move-to-column woman-fill-column)
+    (if (eolp)
+        (forward-line)
+      (if (and (search-backward " " start t)
+               (> (current-column) start-column))
+          (progn
+            (insert-char ?\n 1)
+            (insert-char ?\ (- start-column 5)))
+        (forward-line)))))
+
 \f
 ;;; WoMan message logging:
 

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

* Re: Slight improvement to WoMan tbl handling
  2010-02-17 14:55 Slight improvement to WoMan tbl handling Michael Vehrs
@ 2010-02-19  0:27 ` Glenn Morris
  2010-02-23 16:24   ` Michael Vehrs
       [not found]   ` <sd635nd9g1.fsf@fencepost.gnu.org>
  2010-02-19 13:20 ` Andreas Schwab
  1 sibling, 2 replies; 12+ messages in thread
From: Glenn Morris @ 2010-02-19  0:27 UTC (permalink / raw)
  To: Michael Vehrs; +Cc: emacs-devel


Please could you provide an explanation of what this change is
supposed to do, and a suggested ChangeLog entry? (See etc/CONTRIBUTE
for more details of how to supply patches.) Thanks.




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

* Re: Slight improvement to WoMan tbl handling
  2010-02-17 14:55 Slight improvement to WoMan tbl handling Michael Vehrs
  2010-02-19  0:27 ` Glenn Morris
@ 2010-02-19 13:20 ` Andreas Schwab
  2010-02-19 13:57   ` David Kastrup
  2010-02-20  8:42   ` Michael Vehrs
  1 sibling, 2 replies; 12+ messages in thread
From: Andreas Schwab @ 2010-02-19 13:20 UTC (permalink / raw)
  To: Michael Vehrs; +Cc: emacs-devel

"Michael Vehrs" <michael.burschik@gmx.de> writes:

> +  (let ((pattern (concat "\\(\\\\c\\)?\n[.']" (if pat pat "")))

                                                 (or pat "")

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




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

* Re: Slight improvement to WoMan tbl handling
  2010-02-19 13:20 ` Andreas Schwab
@ 2010-02-19 13:57   ` David Kastrup
  2010-02-20  8:42   ` Michael Vehrs
  1 sibling, 0 replies; 12+ messages in thread
From: David Kastrup @ 2010-02-19 13:57 UTC (permalink / raw)
  To: emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

> "Michael Vehrs" <michael.burschik@gmx.de> writes:
>
>> +  (let ((pattern (concat "\\(\\\\c\\)?\n[.']" (if pat pat "")))
>                                                 (or pat "")

I raise you                                       pat

-- 
David Kastrup





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

* Re: Slight improvement to WoMan tbl handling
  2010-02-19 13:20 ` Andreas Schwab
  2010-02-19 13:57   ` David Kastrup
@ 2010-02-20  8:42   ` Michael Vehrs
  2010-02-20  9:57     ` David Kastrup
  1 sibling, 1 reply; 12+ messages in thread
From: Michael Vehrs @ 2010-02-20  8:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

Andreas Schwab wrote:
> "Michael Vehrs" <michael.burschik@gmx.de> writes:
>
>   
>> +  (let ((pattern (concat "\\(\\\\c\\)?\n[.']" (if pat pat "")))
>>     
>
>                                                  (or pat "")
>
> Andreas.
>   

Thanks. That is, of course, more elegant.

Regards

Michael





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

* Re: Slight improvement to WoMan tbl handling
  2010-02-20  8:42   ` Michael Vehrs
@ 2010-02-20  9:57     ` David Kastrup
  0 siblings, 0 replies; 12+ messages in thread
From: David Kastrup @ 2010-02-20  9:57 UTC (permalink / raw)
  To: emacs-devel

Michael Vehrs <Michael.Burschik@gmx.de> writes:

> Andreas Schwab wrote:
>> "Michael Vehrs" <michael.burschik@gmx.de> writes:
>>
>>   
>>> +  (let ((pattern (concat "\\(\\\\c\\)?\n[.']" (if pat pat "")))
>>>     
>>
>>                                                  (or pat "")
>>
>> Andreas.
>>   
>
> Thanks. That is, of course, more elegant.
>
> Regards

nil and "" behave the same in concat, so just pat is sufficient.

-- 
David Kastrup





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

* Re: Slight improvement to WoMan tbl handling
  2010-02-19  0:27 ` Glenn Morris
@ 2010-02-23 16:24   ` Michael Vehrs
       [not found]   ` <sd635nd9g1.fsf@fencepost.gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Michael Vehrs @ 2010-02-23 16:24 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

Glenn Morris wrote:
> Please could you provide an explanation of what this change is
> supposed to do, and a suggested ChangeLog entry? (See etc/CONTRIBUTE
> for more details of how to supply patches.) Thanks.
>   

OK, next try.

This patch adds support for the "T{ T}" tbl syntax. Since this syntax is 
mainly used for long lines within a table, the patch also adds support 
for filling the last column of a table if the line length would exceed 
fill-column.


diff -cp woman.el.orig woman.el
*** woman.el.orig    2010-02-23 17:16:26.000000000 +0100
--- woman.el    2010-02-23 17:16:34.000000000 +0100
*************** expression in parentheses.  Leaves point
*** 3774,3780 ****
                               (setq fn 'woman2-format-paragraphs))))
                 ()
               ;; Find next control line:
!              (set-marker to (woman-find-next-control-line))
               ;; Call the appropriate function:
               (funcall fn to)))
        (if (not (eobp))            ; This should not happen, but ...
--- 3774,3782 ----
                               (setq fn 'woman2-format-paragraphs))))
                 ()
               ;; Find next control line:
!              (if (equal request "TS")
!                  (set-marker to (woman-find-next-control-line "TE"))
!                (set-marker to (woman-find-next-control-line)))
               ;; Call the appropriate function:
               (funcall fn to)))
        (if (not (eobp))            ; This should not happen, but ...
*************** expression in parentheses.  Leaves point
*** 3785,3796 ****
        (fset 'insert-and-inherit insert-and-inherit)
        (set-marker to nil))))
 
! (defun woman-find-next-control-line ()
    "Find and return start of next control line."
  ;  (let ((to (save-excursion
  ;          (re-search-forward "^\\." nil t))))
  ;    (if to (1- to) (point-max)))
!   (let (to)
      (save-excursion
        ;; Must handle
        ;; ...\c
--- 3787,3799 ----
        (fset 'insert-and-inherit insert-and-inherit)
        (set-marker to nil))))
 
! (defun woman-find-next-control-line (&optional pat)
    "Find and return start of next control line."
  ;  (let ((to (save-excursion
  ;          (re-search-forward "^\\." nil t))))
  ;    (if to (1- to) (point-max)))
!   (let ((pattern (concat "\\(\\\\c\\)?\n[.']" pat))
!         to)
      (save-excursion
        ;; Must handle
        ;; ...\c
*************** expression in parentheses.  Leaves point
*** 3799,3810 ****
        ;; BEWARE THAT THIS CODE MAY BE UNRELIABLE!!!!!
        (while
        (and
!        (setq to (re-search-forward "\\(\\\\c\\)?\n[.']" nil t))
         (match-beginning 1)
         (looking-at "br"))
      (goto-char (match-beginning 0))
      (woman-delete-line 2)))
!     (if to (1- to) (point-max))))
 
  (defun woman2-PD (to)
    ".PD d -- Set the interparagraph distance to d.
--- 3802,3813 ----
        ;; BEWARE THAT THIS CODE MAY BE UNRELIABLE!!!!!
        (while
        (and
!        (setq to (re-search-forward pattern nil t))
         (match-beginning 1)
         (looking-at "br"))
      (goto-char (match-beginning 0))
      (woman-delete-line 2)))
!     (if to (- to (+ 1 (length pat))) (point-max))))
 
  (defun woman2-PD (to)
    ".PD d -- Set the interparagraph distance to d.
*************** Needs doing properly!"
*** 4560,4566 ****
    ".TS -- Start of table code for the tbl processor.
  Format paragraphs upto TO."
    ;; This is a preliminary hack that seems to suffice for lilo.8.
-   (woman-delete-line 1)            ; ignore any arguments
    (when woman-emulate-tbl
      ;; Assumes column separator is \t and intercolumn spacing is 3.
      ;; The first line may optionally be a list of options terminated by
--- 4563,4568 ----
*************** Format paragraphs upto TO."
*** 4572,4577 ****
--- 4574,4595 ----
      (woman-delete-line 1)
      ;; For each column, find its width and align it:
      (let ((start (point)) (col 1))
+       (WoMan-log "%s" (buffer-substring start (+ start 40)))
+       ;; change T{ T} to tabs
+       (while (search-forward "T{\n" to t)
+         (replace-match "")
+         (catch 'end
+           (while (search-forward "\n" to t)
+             (replace-match " ")
+             (if (looking-at "T}")
+                 (progn
+                   (delete-char 2)
+                   (throw 'end t))))))
+       (goto-char start)
+       ;; strip space and headers
+       (while (re-search-forward "^\\.TH\\|\\.sp" to t)
+         (woman-delete-whole-line))
+       (goto-char start)
        (while (prog1 (search-forward "\t" to t) (goto-char start))
      ;; Find current column width:
      (while (< (point) to)
*************** Format paragraphs upto TO."
*** 4587,4593 ****
          (delete-char -1)
          (insert-char ?\  (- col (current-column))))
        (forward-line))
!     (goto-char start))))
    ;; Format table with no filling or adjusting (cf. woman2-nf):
    (setq woman-nofill t)
    (woman2-format-paragraphs to))
--- 4605,4628 ----
          (delete-char -1)
          (insert-char ?\  (- col (current-column))))
        (forward-line))
!         (goto-char start))
!       ;; find maximum width
!       (let ((max-col 0))
!         (while (search-forward "\n" to t)
!           (backward-char)
!           (if (> (current-column) max-col)
!               (setq max-col (current-column)))
!           (forward-char))         
!         (goto-char start)
!         ;; break lines if they are too long
!         (when (and (> max-col woman-fill-column)
!                    (> woman-fill-column col))
!           (setq max-col woman-fill-column)
!           (woman-break-table col to)
!           (goto-char start))         
!         (while (re-search-forward "^_$" to t)
!           (replace-match (make-string max-col ?_)))
!         (goto-char start))))
    ;; Format table with no filling or adjusting (cf. woman2-nf):
    (setq woman-nofill t)
    (woman2-format-paragraphs to))
*************** Format paragraphs upto TO."
*** 4596,4601 ****
--- 4631,4648 ----
    ;; ".TE -- End of table code for the tbl processor."
    ;; Turn filling and adjusting back on.
 
+ (defun woman-break-table (start-column to)
+   (while (< (point) to)
+     (move-to-column woman-fill-column)
+     (if (eolp)
+         (forward-line)
+       (if (and (search-backward " " start t)
+                (> (current-column) start-column))
+           (progn
+             (insert-char ?\n 1)
+             (insert-char ?\ (- start-column 5)))
+         (forward-line)))))
+
 

  ;;; WoMan message logging:
 





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

* bug#5635: Slight improvement to WoMan tbl handling
       [not found]   ` <sd635nd9g1.fsf@fencepost.gnu.org>
@ 2012-04-10 23:44     ` Lars Magne Ingebrigtsen
  2012-04-12 17:33       ` Michael Vehrs
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-10 23:44 UTC (permalink / raw)
  To: Michael Vehrs; +Cc: 5635

Michael Vehrs <Michael.Burschik@gmx.de> writes:

> This patch adds support for the "T{ T}" tbl syntax. Since this syntax is 
> mainly used for long lines within a table, the patch also adds support 
> for filling the last column of a table if the line length would exceed 
> fill-column.

Looks good, I think.  But a patch of this size needs FSF copyright
assignment papers signed.  Do you have such paperwork on file, and if
not, would you be willing to sign such papers?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





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

* bug#5635: Slight improvement to WoMan tbl handling
  2012-04-10 23:44     ` bug#5635: " Lars Magne Ingebrigtsen
@ 2012-04-12 17:33       ` Michael Vehrs
  2012-04-12 17:46         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Vehrs @ 2012-04-12 17:33 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 5635

On 11.04.2012 01:44, Lars Magne Ingebrigtsen wrote:
> Michael Vehrs<Michael.Burschik@gmx.de>  writes:
>
>    
>> This patch adds support for the "T{ T}" tbl syntax. Since this syntax is
>> mainly used for long lines within a table, the patch also adds support
>> for filling the last column of a table if the line length would exceed
>> fill-column.
>>      
> Looks good, I think.  But a patch of this size needs FSF copyright
> assignment papers signed.  Do you have such paperwork on file, and if
> not, would you be willing to sign such papers?
>    

I am willing to sign, but I do not have the papers at hand.

Regards

Michael







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

* bug#5635: Slight improvement to WoMan tbl handling
  2012-04-12 17:33       ` Michael Vehrs
@ 2012-04-12 17:46         ` Lars Magne Ingebrigtsen
  2012-04-12 17:56           ` Michael Vehrs
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-12 17:46 UTC (permalink / raw)
  To: Michael Vehrs; +Cc: 5635

Michael Vehrs <Michael.Burschik@gmx.de> writes:

> I am willing to sign, but I do not have the papers at hand.

Great!

Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]

[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]

[For the copyright registration, what country are you a citizen of?]

[What year were you born?]

[Please write your email address here.]

[Please write your postal address here.]

[Which files have you changed so far, and which new files have you written
so far?]

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





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

* bug#5635: Slight improvement to WoMan tbl handling
  2012-04-12 17:46         ` Lars Magne Ingebrigtsen
@ 2012-04-12 17:56           ` Michael Vehrs
  2012-04-21  5:55             ` Chong Yidong
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Vehrs @ 2012-04-12 17:56 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 5635

On 12.04.2012 19:46, Lars Magne Ingebrigtsen wrote:
> Michael Vehrs<Michael.Burschik@gmx.de>  writes:
>
>    
>> I am willing to sign, but I do not have the papers at hand.
>>      
> Great!
>
> Please email the following information to assign@gnu.org, and we
> will send you the assignment form for your past and future changes.
>
> Please use your full legal name (in ASCII characters) as the subject
> line of the message.
>    

Done.


Regards

Michael

> ----------------------------------------------------------------------
> REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
>
> [What is the name of the program or package you're contributing to?]
> Emacs
>
> [Did you copy any files or text written by someone else in these changes?
> Even if that material is free software, we need to know about it.]
>
> [Do you have an employer who might have a basis to claim to own
> your changes?  Do you attend a school which might make such a claim?]
>
> [For the copyright registration, what country are you a citizen of?]
>
> [What year were you born?]
>
> [Please write your email address here.]
>
> [Please write your postal address here.]
>
> [Which files have you changed so far, and which new files have you written
> so far?]
>
>    






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

* bug#5635: Slight improvement to WoMan tbl handling
  2012-04-12 17:56           ` Michael Vehrs
@ 2012-04-21  5:55             ` Chong Yidong
  0 siblings, 0 replies; 12+ messages in thread
From: Chong Yidong @ 2012-04-21  5:55 UTC (permalink / raw)
  To: Michael Vehrs; +Cc: Lars Magne Ingebrigtsen, 5635

Your copyright assignment has come through, and I've committed your
patch to trunk.  Thanks for your contribution.





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

end of thread, other threads:[~2012-04-21  5:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-17 14:55 Slight improvement to WoMan tbl handling Michael Vehrs
2010-02-19  0:27 ` Glenn Morris
2010-02-23 16:24   ` Michael Vehrs
     [not found]   ` <sd635nd9g1.fsf@fencepost.gnu.org>
2012-04-10 23:44     ` bug#5635: " Lars Magne Ingebrigtsen
2012-04-12 17:33       ` Michael Vehrs
2012-04-12 17:46         ` Lars Magne Ingebrigtsen
2012-04-12 17:56           ` Michael Vehrs
2012-04-21  5:55             ` Chong Yidong
2010-02-19 13:20 ` Andreas Schwab
2010-02-19 13:57   ` David Kastrup
2010-02-20  8:42   ` Michael Vehrs
2010-02-20  9:57     ` David Kastrup

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.