Skip to content

Commit a1b85df

Browse files
committed
Nicer editing of labels associated to environments
1 parent 037885d commit a1b85df

File tree

5 files changed

+106
-4
lines changed

5 files changed

+106
-4
lines changed

TeXmacs/progs/generic/generic-edit.scm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,33 @@
10451045
(insert `(video ,(url->delta-unix u) ,w ,h ,len ,rep)))
10461046
"Width" "Height" "Length" "Repeat?"))
10471047

1048+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1049+
;; Labels attached to markup
1050+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1051+
1052+
(tm-define (focus-label t) #f)
1053+
1054+
(tm-define (focus-get-label t)
1055+
(and-with l (focus-label t)
1056+
(tm->string (tm-ref l 0))))
1057+
1058+
(tm-define (focus-set-label t val)
1059+
(and-with l (focus-label t)
1060+
(tree-set l 0 val)))
1061+
1062+
(tm-define (focus-list-search-label l)
1063+
(and (nnull? l)
1064+
(or (focus-search-label (car l))
1065+
(focus-list-search-label (cdr l)))))
1066+
1067+
(tm-define (focus-search-label t)
1068+
(cond ((tm-func? t 'label 1) t)
1069+
((tm-in? t '(document concat table row cell))
1070+
(focus-list-search-label (tm-children t)))
1071+
((tm-in? t '(tformat with surround))
1072+
(focus-search-label (cAr (tm-children t))))
1073+
(else #f)))
1074+
10481075
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10491076
;; Special keyboard behaviour when entering hybrid commands
10501077
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TeXmacs/progs/generic/generic-menu.scm

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,14 @@
583583
(tm-menu (focus-hidden-menu t)
584584
(:require (pure-alternate-context? t)))
585585

586+
(tm-menu (focus-label-menu t)
587+
(assuming (focus-label t)
588+
---
589+
(with s (focus-get-label t)
590+
((eval (string-append "#" s))
591+
(interactive (lambda (l) (focus-set-label t l))
592+
(list "Label" "string" s))))))
593+
586594
(tm-menu (standard-focus-menu t)
587595
(dynamic (focus-ancestor-menu t))
588596
(dynamic (focus-tag-menu t))
@@ -593,7 +601,8 @@
593601
---
594602
(dynamic (focus-insert-menu t)))
595603
(dynamic (focus-extra-menu t))
596-
(dynamic (focus-hidden-menu t)))
604+
(dynamic (focus-hidden-menu t))
605+
(dynamic (focus-label-menu t)))
597606

598607
(tm-menu (focus-menu)
599608
(dynamic (standard-focus-menu (focus-tree))))
@@ -718,6 +727,14 @@
718727
(tm-menu (focus-hidden-icons t)
719728
(:require (pure-alternate-context? t)))
720729

730+
(tm-menu (focus-label-icons t)
731+
(assuming (focus-label t)
732+
(with s (focus-get-label t)
733+
(glue #f #f 3 0)
734+
(mini #t (group "Label:"))
735+
(mini #t (input (focus-set-label (focus-tree) answer) "string"
736+
(list s) "12em")))))
737+
721738
(tm-menu (standard-focus-icons t)
722739
(dynamic (focus-ancestor-icons t))
723740
(assuming (focus-can-move? t)
@@ -727,8 +744,9 @@
727744
(minibar (dynamic (focus-insert-icons t)))
728745
//)
729746
(minibar (dynamic (focus-tag-icons t)))
730-
(dynamic (focus-extra-icons t))
731747
(dynamic (focus-hidden-icons t))
748+
(dynamic (focus-extra-icons t))
749+
(dynamic (focus-label-icons t))
732750
//)
733751

734752
(tm-menu (texmacs-focus-icons)

TeXmacs/progs/link/ref-edit.scm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@
176176
(:applicable (broken-citations))
177177
(list-go-to (broken-citations) dir))
178178

179+
(tm-define (special-extremal t forwards?)
180+
(:require (focus-label t))
181+
(with lab (focus-label t)
182+
(tree-go-to lab :end)
183+
(special-extremal lab forwards?)))
184+
185+
(tm-define (special-incremental t forwards?)
186+
(:require (focus-label t))
187+
(with lab (focus-label t)
188+
(tree-go-to lab :end)
189+
(special-incremental lab forwards?)))
190+
179191
(tm-define (special-extremal t forwards?)
180192
(:require (tie-context? t))
181193
(go-to-same-tie (if forwards? :last :first)))

TeXmacs/progs/table/table-menu.scm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@
369369
(if (== (get-cell-mode) "table") (group "Cells"))
370370
(link cell-menu)
371371
(dynamic (focus-extra-menu t))
372-
(dynamic (focus-hidden-menu t)))
372+
(dynamic (focus-hidden-menu t))
373+
(dynamic (focus-label-menu t)))
373374

374375
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
375376
;; Icons for manipulation of tables

TeXmacs/progs/text/text-edit.scm

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@
318318
(tree-go-to t :end)
319319
(make 'label))
320320

321+
(tm-define (focus-label t)
322+
(:require (section-context? t))
323+
(and-with p (tree-up t)
324+
(and (tm-func? p 'concat)
325+
(focus-search-label p))))
326+
321327
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
322328
;; Routines for lists, enumerations and description
323329
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -358,6 +364,13 @@
358364
(:require (tree-is? t 'item*))
359365
(go-end-of 'item*))
360366

367+
(tm-define (focus-label t)
368+
(:require (or (list-context? t) (tree-is? t 'bib-list)))
369+
(and-with doc (tree-down t)
370+
(and (tree-is? doc 'document)
371+
(and-with par (tree-down doc)
372+
(focus-search-label par)))))
373+
361374
(tm-define (numbered-context? t)
362375
(:require (or (itemize-context? t) (enumerate-context? t)))
363376
#t)
@@ -399,7 +412,7 @@
399412
(insert ins)))
400413

401414
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
402-
;; Inserting formulas
415+
;; Formulas
403416
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
404417

405418
(tm-define (make-equation)
@@ -417,6 +430,21 @@
417430
(make 'eqnarray*)
418431
(temp-proof-fix))
419432

433+
(tm-define (focus-label t)
434+
(:require (tree-is? t 'equation))
435+
(focus-list-search-label (tree-children t)))
436+
437+
(define (down-to-row t)
438+
(cond ((not (tree? t)) #f)
439+
((tree-is? t 'row) t)
440+
((tree-in? t '(document tformat table)) (down-to-row (tree-down t)))
441+
(else #f)))
442+
443+
(tm-define (focus-label t)
444+
(:require (tree-in? t '(eqnarray eqnarray*)))
445+
(and-with row (down-to-row (tree-down t))
446+
(focus-search-label row)))
447+
420448
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
421449
;; Routines for inserting miscellaneous content
422450
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -505,6 +533,11 @@
505533
(tree-go-to t :last :start)
506534
(make 'dueto))
507535

536+
(tm-define (focus-label t)
537+
(:require (tree-in? t (enunciation-tag-list)))
538+
(and (== (tree-arity t) 1)
539+
(focus-search-label (tree-ref t 0))))
540+
508541
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509542
;; Editing algorithms
510543
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -584,6 +617,10 @@
584617
(tree-insert! t (- (tree-arity t) 1) '((document "")))
585618
(tree-go-to t (- (tree-arity t) 2) :start)))))
586619

620+
(tm-define (focus-label t)
621+
(:require (algorithm-context? t))
622+
(focus-list-search-label (tree-children t)))
623+
587624
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
588625
;; Possible to use a custom note symbol
589626
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -797,6 +834,9 @@
797834
(tm-define (footnote-context? t)
798835
(tree-in? t '(footnote wide-footnote)))
799836

837+
(tm-define (figure-context? t)
838+
(tree-in? t (figure-tag-list)))
839+
800840
(tm-define (float-or-footnote-context? t)
801841
(tree-in? t '(float wide-float footnote wide-footnote)))
802842

@@ -911,3 +951,7 @@
911951
(if (cursor-at-anchor?)
912952
(go-to-float)
913953
(go-to-anchor)))
954+
955+
(tm-define (focus-label t)
956+
(:require (or (footnote-context? t) (figure-context? t)))
957+
(focus-list-search-label (tree-children t)))

0 commit comments

Comments
 (0)