home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / pmcstex.zip / install / pm_keys.e (.txt) < prev    next >
LaTeX Document  |  2000-04-14  |  3KB  |  104 lines

  1.   pm_keys.e by Petr Mikulik, http://www.sci.muni.cz/~mikulik/
  2.   Some my favourite key sequences are defined here.
  3.   This file is in public domain.
  4.   This file belongs to the "pmCSTeX for EPM" package, see 
  5.     http://www.sci.muni.cz/~mikulik/os2/pmCSTeX.html
  6.   or pmcstex.zip on hobbes, leo and CTAN archives.
  7. -- CTRL/Y deletes line
  8. def C_Y = 
  9. deleteline; .col=1
  10. -- Alt-1  generalizes the EPM's include file function
  11. def A_1 = 
  12. 'cstex_include S'
  13. -- Alt-3 inserts \begin{}
  14. def A_3 =
  15.   getline x; replaceline( insertstr('\begin{}',x,.col-1) )
  16.   .col=.col+7
  17. -- Alt-4 inserts \end{}
  18. def A_4 =
  19.   getline x; replaceline( insertstr('\end{}',x,.col-1) )
  20.   .col=.col+5
  21. -- Alt-5 inserts \[  \]
  22. def A_5 =
  23.   if .col>1 then .line=.line+1; endif 
  24.   insertline '%'
  25.   insertline '\['
  26.   insertline ''
  27.   insertline '\]'
  28.   insertline '%'
  29.   .col=1
  30.   .line=.line-3
  31. -- Alt-6 inserts $$  $$
  32. def A_6 =
  33.   if .col>1 then .line=.line+1; endif 
  34.   insertline '%'
  35.   insertline '$$'
  36.   insertline ''
  37.   insertline '$$'
  38.   insertline '%'
  39.   .col=1
  40.   .line=.line-3
  41. -- Alt-W  unmarks, then calls the default EPM action for word marking, and 
  42. -- finally puts the marked text into the clipboard
  43. def a_w = 
  44. if marktype()<>'' then unmark; endif
  45. call pmark_word()
  46. 'copy2clip'
  47. -- Alt-Z margins for e-mailed documents, TeX files and programs
  48. def A_Z =
  49. ma2='ma 1 1599 1'; ma3='ma 1 80 1'; ma4='ma 1 75 1'
  50. s=entrybox('Set margins','/OK/'ma2'/'ma3'/'ma4,'ma '.margins,30,30)
  51. if     s=4 then s=ma4
  52. elseif s=3 then s=ma3
  53. elseif s='' then s=ma2
  54. endif
  55. Definition of the Alt-Q hotkey. It provides the following two actions:
  56. 1. quickly makes \begin{equation} ... \end{equation} environment with two
  57.    two comment lines above and below. Thus pressing Alt-Q on this line would do:
  58.    \begin{equation}
  59.    \end{equation}
  60. 2. If you put the cursor over the line containing only the string 
  61. \begin{..} or \end{..}, where XX is equation, eqnarray, align, equation*, 
  62. eqnarray*, align*, then instead of the function 1. the text on this line
  63. is changed to the next environment in this list. 
  64.   Useful if you add one more equation into an \begin{equation}.
  65. Note for future: this could be more powerful if this command would change 
  66. both \begin{..} and \end{..} simultaneously.
  67. def A_Q = 
  68. if (not wordpos(filetype(), 'TEX LATEX STY CLS DTX') ) then
  69.   sayerror 'pm_keys: Alt-Q does not work on non-TeX files'
  70.   return
  71.   endif
  72. getline S
  73. B='\begin{'; E='\end{'
  74. s1='equation}'; s2='eqnarray}'; s3='align}'
  75. if    S=B''s1    then    S=B''s2
  76. elseif    S=B''s2    then    S=B''s3
  77. elseif    S=B''s3    then    S=B''s1
  78. elseif    S=E''s1    then    S=E''s2
  79. elseif    S=E''s2    then    S=E''s3
  80. elseif    S=E''s3    then    S=E''s1
  81. else 
  82. s1='equation*}'; s2='eqnarray*}'; s3='align*}'
  83. if    S=B''s1    then    S=B''s2
  84. elseif    S=B''s2    then    S=B''s3
  85. elseif    S=B''s3    then    S=B''s1
  86. elseif    S=E''s1    then    S=E''s2
  87. elseif    S=E''s2    then    S=E''s3
  88. elseif    S=E''s3    then    S=E''s1
  89. else 
  90.   -- inserting the \begin{equation} ... \end{equation}
  91.   if .col>1 then .line=.line+1; endif
  92.   insertline '%'; insertline '\begin{equation}'
  93.   insertline ''
  94.   insertline '\end{equation}'; insertline '%'
  95.   .line=.line-3
  96.   .col=1
  97.   return
  98. endif
  99. endif
  100. replaceline S  -- finishing the replacement mode
  101. -- syntax highlighting on
  102. defload
  103. 'a_togl_hilit S'
  104.