ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* About \defineshortcut
@ 2005-12-15 21:31 Radhelorn
  2005-12-16 19:18 ` Taco Hoekwater
  0 siblings, 1 reply; 8+ messages in thread
From: Radhelorn @ 2005-12-15 21:31 UTC (permalink / raw)


Hello All!

There is intresting macros in cont-new -- shortcuts. It works pretty 
well, but I have one question: how to undefine them back?

For example after command:

\defineshortcut [//] [] [style=\em]

I can get slash only by \textslash (which is expected) and it breaks 
things like:

\typefile {some/dir/file}

So how to revert to previous meaning of '/'? It is possible to do it 
only temporarily?

-- 
Radhelorn <radhelorn@mail.ru>

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

* Re: About \defineshortcut
  2005-12-15 21:31 About \defineshortcut Radhelorn
@ 2005-12-16 19:18 ` Taco Hoekwater
  2005-12-17 12:38   ` Radhelorn
  2005-12-20 21:37   ` Radhelorn
  0 siblings, 2 replies; 8+ messages in thread
From: Taco Hoekwater @ 2005-12-16 19:18 UTC (permalink / raw)


Radhelorn wrote:
> Hello All!
> 
> There is intresting macros in cont-new -- shortcuts. It works pretty 
> well, but I have one question: how to undefine them back?
> 
> For example after command:
> 
> \defineshortcut [//] [] [style=\em]

> I can get slash only by \textslash (which is expected) and it breaks 
> things like:
> 
> \typefile {some/dir/file}
> 
> So how to revert to previous meaning of '/'? It is possible to do it 
> only temporarily?

Explicit \start a /b/ c \stop style grouping is normally best, but
a shortcut is just an active character with a closing defimiter,
so this will work for you special case:

   \catcode`\/=\other
   \typefile {some/dir/file}
   \catcode`\/=\active


Cheers, taco

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

* Re: About \defineshortcut
  2005-12-16 19:18 ` Taco Hoekwater
@ 2005-12-17 12:38   ` Radhelorn
  2005-12-17 13:49     ` Taco Hoekwater
  2005-12-20 21:37   ` Radhelorn
  1 sibling, 1 reply; 8+ messages in thread
From: Radhelorn @ 2005-12-17 12:38 UTC (permalink / raw)


Taco Hoekwater wrote:
> Radhelorn wrote:
> 
>> Hello All!
>>
>> There is intresting macros in cont-new -- shortcuts. It works pretty 
>> well, but I have one question: how to undefine them back?
>>
>> For example after command:
>>
>> \defineshortcut [//] [] [style=\em]
> 
> 
>> I can get slash only by \textslash (which is expected) and it breaks 
>> things like:
>>
>> \typefile {some/dir/file}
>>
>> So how to revert to previous meaning of '/'? It is possible to do it 
>> only temporarily?
> 
> 
> Explicit \start a /b/ c \stop style grouping is normally best, but
> a shortcut is just an active character with a closing defimiter,
> so this will work for you special case:
> 
>   \catcode`\/=\other
>   \typefile {some/dir/file}
>   \catcode`\/=\active
> 
> 

Thanks Taco. I was experimenting with \bgroup \egroup and thinking about 
some more explicit and visible. BTW where is these \start \stop defined?

-- 
Radhelorn <radhelorn@mail.ru>

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

* Re: About \defineshortcut
  2005-12-17 12:38   ` Radhelorn
@ 2005-12-17 13:49     ` Taco Hoekwater
  0 siblings, 0 replies; 8+ messages in thread
From: Taco Hoekwater @ 2005-12-17 13:49 UTC (permalink / raw)


Radhelorn wrote:
> Thanks Taco. I was experimenting with \bgroup \egroup and thinking about 
> some more explicit and visible. BTW where is these \start \stop defined?

core-sys.tex, line 128-136:

   \def\complexstart[#1]{\bgroup\getvalue{\e!start#1}}
   \def\complexstop [#1]{\getvalue{\e!stop #1}\egroup}

   \let\simplestart\bgroup
   \let\simplestop \egroup

   \definecomplexorsimple\start
   \definecomplexorsimple\stop

Cheers,

Taco

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

* Re: About \defineshortcut
  2005-12-16 19:18 ` Taco Hoekwater
  2005-12-17 12:38   ` Radhelorn
@ 2005-12-20 21:37   ` Radhelorn
  2005-12-20 22:28     ` Hans Hagen
  1 sibling, 1 reply; 8+ messages in thread
From: Radhelorn @ 2005-12-20 21:37 UTC (permalink / raw)


Taco Hoekwater wrote:
>> For example after command:
>>
>> \defineshortcut [//] [] [style=\em]
> 
>> I can get slash only by \textslash (which is expected) and it breaks 
>> things like:
>>
>> \typefile {some/dir/file}
>>
>> So how to revert to previous meaning of '/'? It is possible to do it 
>> only temporarily?
> 
> Explicit \start a /b/ c \stop style grouping is normally best, but
> a shortcut is just an active character with a closing defimiter,
> so this will work for you special case:
> 
>   \catcode`\/=\other
>   \typefile {some/dir/file}
>   \catcode`\/=\active
> 

I've experimented with various macros to undefine/temporarily disable 
shortcuts and found that most convenient variant is to insert this 
catcode changing into \typefile command. Why not to do this for every 
command, that accepts path parameters? This slows process down too much?

But this is just an afterthought.

I think that \defineshortcut commands are most useful inside some 
environment (start/stop pair). So it is possible to have such 
environment that restores back all catcode changes (or other variable 
changes) made inside it (like local variables in some programming 
laguages)? This can have many other uses.

-- 
Radhelorn <radhelorn@mail.ru>

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

* Re: About \defineshortcut
  2005-12-20 21:37   ` Radhelorn
@ 2005-12-20 22:28     ` Hans Hagen
  2005-12-21  7:53       ` Radhelorn
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2005-12-20 22:28 UTC (permalink / raw)


Radhelorn wrote:

> Taco Hoekwater wrote:
>
>>> For example after command:
>>>
>>> \defineshortcut [//] [] [style=\em]
>>
>>
>>> I can get slash only by \textslash (which is expected) and it breaks 
>>> things like:
>>>
>>> \typefile {some/dir/file}
>>>
>>> So how to revert to previous meaning of '/'? It is possible to do it 
>>> only temporarily?
>>
>>
>> Explicit \start a /b/ c \stop style grouping is normally best, but
>> a shortcut is just an active character with a closing defimiter,
>> so this will work for you special case:
>>
>>   \catcode`\/=\other
>>   \typefile {some/dir/file}
>>   \catcode`\/=\active
>>
>
> I've experimented with various macros to undefine/temporarily disable 
> shortcuts and found that most convenient variant is to insert this 
> catcode changing into \typefile command. Why not to do this for every 
> command, that accepts path parameters? This slows process down too much?
>
> But this is just an afterthought.
>
> I think that \defineshortcut commands are most useful inside some 
> environment (start/stop pair). So it is possible to have such 
> environment that restores back all catcode changes (or other variable 
> changes) made inside it (like local variables in some programming 
> laguages)? This can have many other uses.
>
i have no idea why you use shortcuts (i implemented it as a gimmick -)

grouping is doable with:

\starttext

\startsetups whatever
    \defineshortcut [b] [style=bold]
    \defineshortcut [e] [style=slanted]
\stopsetups

\definestartstop[whatever][commands=\setups{whatever}]

\input tufte

oeps <b:oeps> or <e:oeps>

\startwhatever
oeps <b:oeps> or <e:oeps>
\stopwhatever

oeps <b:oeps> or <e:oeps>

\input tufte

\stoptext

Hans

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

* Re: About \defineshortcut
  2005-12-20 22:28     ` Hans Hagen
@ 2005-12-21  7:53       ` Radhelorn
  2005-12-21  9:06         ` Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Radhelorn @ 2005-12-21  7:53 UTC (permalink / raw)


Hans Hagen wrote:
> Radhelorn wrote:
>> I think that \defineshortcut commands are most useful inside some 
>> environment (start/stop pair). So it is possible to have such 
>> environment that restores back all catcode changes (or other variable 
>> changes) made inside it (like local variables in some programming 
>> laguages)? This can have many other uses.
>>
> i have no idea why you use shortcuts (i implemented it as a gimmick -)

Well I was reading sources and stumbled over these commands. I am using 
shortcuts to typeset programming examples in non standard languages and 
pseudo-code.

> 
> grouping is doable with:
> 
> \starttext
> 
> \startsetups whatever
>    \defineshortcut [b] [style=bold]
>    \defineshortcut [e] [style=slanted]
> \stopsetups
> 
> \definestartstop[whatever][commands=\setups{whatever}]
> 
> \input tufte
> 
> oeps <b:oeps> or <e:oeps>
> 
> \startwhatever
> oeps <b:oeps> or <e:oeps>
> \stopwhatever
> 
> oeps <b:oeps> or <e:oeps>
> 
> \input tufte
> 
> \stoptext
> 

Many thanks! I've looked this indeed!

It is a pity that such useful command (setups) remains undocumented. As 
far as I understand inside setups can be any commands and environment 
changes are fully restored after their execution. Right? And \setups 
command can replace any single command (in arguments and such).

If this is OK, then I will try to collect some more examples and post 
them on the WIKI later this week.

-- 
Radhelorn <radhelorn@mail.ru>

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

* Re: About \defineshortcut
  2005-12-21  7:53       ` Radhelorn
@ 2005-12-21  9:06         ` Hans Hagen
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen @ 2005-12-21  9:06 UTC (permalink / raw)


Radhelorn wrote:

> It is a pity that such useful command (setups) remains undocumented. 
> As far as I understand inside setups can be any commands and 
> environment changes are fully restored after their execution. Right? 
> And \setups command can replace any single command (in arguments and 
> such).

catcode changes are always tricky; if you make a style that uses them 
you also need to make sure that they will not clash with other changes 
(e.g. in the otr); nowadays, an active < is not that much of a problem 
since this is what the xml parser does anyway and context knows how to 
deal with that

>
> If this is OK, then I will try to collect some more examples and post 
> them on the WIKI later this week.
>
ok, or maybe a myway document ...

Hans

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

end of thread, other threads:[~2005-12-21  9:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-15 21:31 About \defineshortcut Radhelorn
2005-12-16 19:18 ` Taco Hoekwater
2005-12-17 12:38   ` Radhelorn
2005-12-17 13:49     ` Taco Hoekwater
2005-12-20 21:37   ` Radhelorn
2005-12-20 22:28     ` Hans Hagen
2005-12-21  7:53       ` Radhelorn
2005-12-21  9:06         ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).