On the customizations of personal styles [the scheme way]

There’re some tips on the scheme way to customize your personal style of notes. I found it easier to work with in some situations but won’t advocate it over the .ts file way in any sense. You decide how to organize your personal stuff.

It’s well known that TEXMACS_HOME_PATH/progs/my-init-buffer.scm is evaluated when a buffer is being loaded. Suppose you wanna include in every NEW note files package smart-ref and preview-ref, assign some values like <assign|info-flag|detailed>, and define some macros like <assign|ket|<macro|x||x<rangle>>>. Here is how you can realize them in your my-init-buffer.scm:

(define (my-style-list)
  ;; packages to include
  '("preview-ref" "smart-ref"
    ))

(define (my-package-general)
  ;; some things to define in the preamble
  '((assign "info-flag" "detailed")
    ))

(define (my-package-dirac)
  ;; some other things to be put in preamble, more organized
  '((assign "bra" (macro "x" (concat "<langle>" (arg "x") "|")))
    (assign "ket" (macro "x" (concat "|" (arg "x") "<rangle>")))
    (assign "braket" (macro "x" "y"
                            (concat "<langle>" (arg "x") "|" (arg "y") "<rangle>")))
    (assign "ketbra" (macro "x" "y"
                            (concat "|" (arg "x") "<rangle><langle>" (arg "y") "|")))
    (assign "bok" (macro "left" "op" "right"
                         (concat "<langle>" (arg "left") "|" (arg "op") "|" (arg "right") "<rangle>")))))

(if (not (buffer-has-name? (current-buffer))) ; only execute when a buffer not linked to any file is created
    (begin
      (init-style "article")  ; initial style to be `article'

      (set-style-list (append (get-style-list) (my-style-list))) ; set the style list to include your prescribed packages

      (with t (buffer-tree)   ; put your stuff in the preamble
        (tree-insert! t 0 `((hide-preamble (document
                                            ,@(my-package-general)
                                            ,@(my-package-dirac))))))

      (buffer-pretend-saved (current-buffer))))
4 Likes

This would be a nice contribution to the wiki post [wiki] Assorted code snippets to customize TeXmacs' behaviour

That post, even if pinned, keeps slipping away, and I don’t know if it is better to find a stronger way to pin it or to figure out something else (perhaps start the TeXmacs wiki I have in mind since some time).

Here are two posts on the topic “pinning” (I don’t have access to the settings that might change the behaviour of pinned posts), so only forum administrators would be able to set the posts behaviour differently.


1 Like

THis looks relevant:

http://forum.texmacs.cn/t/read-me-first-admin-quick-start-guide/9

1 Like

It would also be nice to compile the interesting snippets into a blog article for texmacs’ notes : https://texmacs.github.io/notes/docs/main.html then would be easy to add more as PRs.

For those of you which are intrepid, one would also like to have a texmacs extension which allow to automatically submit PR to the blog :slight_smile:

1 Like

Or we can have forum admins adding category tag must read to posts of interesting snippets or something else, and put in the https://texmacs.github.io/notes/docs/main.html, and other entry places of TeXmacs of course, links to that category in the forum. It would the most admin-friendly way. When they scroll over the forum and found something interesting, they just click and add a new category to it…

1 Like