Re: A basic programming problem.

Giovanni Piredda <[email protected]> Tue, 07 Apr 2026 19:36:30 +0000
Newsgroups gmane.editors.texmacs.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------yczop1JjUjgoNBLJrUa6YAjU
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi David,

I don't think that these are basic questions, in that you are 
programming with an interface for which there are just a few examples so 
you may have to test your programs step by step on your own.

This said, I got the following to work

<assign|mc|<macro|type|<extern|set-color|<arg|type>>>>

<assign|testextern|<macro|type|<with|color|<mc|<arg|type>>|testwrite>>>

(tm-define (set-color type)
   (stree->tree
    (cond ((equal? (tree->stree type) "emph") "red")
         ((equal? (tree->stree type) "stat") "blue")
         (else "black"))))


Perhaps you will find by comparison what is not working in your code. I 
can test your code too if necessary, I would need the Scheme code as well.

> PS 1 : I wrote a Scheme function because the documentation seems to 
> say that conditional structures, or case, are not very reliable. Is 
> that true?
>
I don't know, let's see if someone else answers

> PS 2 : Could you tell me which keyboard configuration is needed to 
> work efficiently on a style file under macOS? The keyboard shortcuts 
> for writing work fine, but the ones for programming do not. It is 
> therefore quite frustrating to have to keep using the mouse and the 
> drop-down menus all the time.
>
I think you need to absorb the keyboard behaviour for programming "by 
osmosis". I am not aware of a document where the keyboard behaviour is 
explained. While I do think such a document would be very helpful, I 
don't think I am able to write one, both because I do not have the time 
*and* I do not know the behaviour in a complete and systematic way.

Let me give you one tip: you need to observe what the keys return, 
backspace and the arrows do according to the cursor position (maybe 
according to the surrounding code too, but I may be wrong and there is 
no such dependency). For example when you are inside a macro argument, 
next to the macro name, backspace will let you edit the macro name.

--------------yczop1JjUjgoNBLJrUa6YAjU
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi David,</p>
    <p>I don't think that these are basic questions, in that you are
      programming with an interface for which there are just a few
      examples so you may have to test your programs step by step on
      your own.</p>
    <p>This said, I got the following to work</p>
    <p>&lt;assign|mc|&lt;macro|type|&lt;extern|set-color|&lt;arg|type&gt;&gt;&gt;&gt;</p>
    <p>&lt;assign|testextern|&lt;macro|type|&lt;with|color|&lt;mc|&lt;arg|type&gt;&gt;|testwrite&gt;&gt;&gt;</p>
    <p>(tm-define (set-color type)<br>
        (stree-&gt;tree <br>
         (cond ((equal? (tree-&gt;stree type) "emph") "red")<br>
              ((equal? (tree-&gt;stree type) "stat") "blue")<br>
              (else "black"))))</p>
    <p><br>
    </p>
    <p>Perhaps you will find by comparison what is not working in your
      code. I can test your code too if necessary, I would need the
      Scheme code as well.</p>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <div>
        <div>
          <p class="p3">PS 1 : I wrote a Scheme function because the
            documentation seems to say that conditional structures, or <span
              class="s1">case</span>, are not very reliable. Is that
            true?</p>
        </div>
      </div>
    </blockquote>
    <p>I don't know, let's see if someone else answers</p>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <div>
        <div>
          <p class="p3">PS 2 : Could you tell me which keyboard
            configuration is needed to work efficiently on a style file
            under macOS? The keyboard shortcuts for writing work fine,
            but the ones for programming do not. It is therefore quite
            frustrating to have to keep using the mouse and the
            drop-down menus all the time.</p>
        </div>
      </div>
    </blockquote>
    <p>I think you need to absorb the keyboard behaviour for programming
      "by osmosis". I am not aware of a document where the keyboard
      behaviour is explained. While I do think such a document would be
      very helpful, I don't think I am able to write one, both because I
      do not have the time *and* I do not know the behaviour in a
      complete and systematic way.</p>
    <p>Let me give you one tip: you need to observe what the keys
      return, backspace and the arrows do according to the cursor
      position (maybe according to the surrounding code too, but I may
      be wrong and there is no such dependency). For example when you
      are inside a macro argument, next to the macro name, backspace
      will let you edit the macro name.</p>
  </body>
</html>

--------------yczop1JjUjgoNBLJrUa6YAjU--