Re: editing DCL

2010-12-21 Fir de Conversatie Charles Campbell

Hello!

Here's my latest try at helping with DCL's $s:

au BufWinEnter * if &ft == "dcl"|%s/^\$//e|setlocal nomod|endif
au BufWrite* if &ft == "dcl"
au BufWrite* 1,$-1g/[^\-]$/.+1,.+1s/^/$/e
au BufWrite* 1,1s/^/$/e|endif

Enjoy!
Chip Campbell

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-21 Fir de Conversatie Charles Campbell



On Dec 18, 3:58 am, Charles E Campbell Jr
wrote:
   

Samuel Ferencik wrote:
 

Hi,
   
 

DCL is a scripting language for OpenVMS, whose lines of code must all
start with a $.
   
 

Here is a code excerpt (from
http://www.eight-cubed.com/articles/dcl_standards.html):
   
 

|||$   on warning then goto nopriv
 $   set on
 $   set process/privilege=(sysnam,sysprv)
 $!...
   
 

 $nopriv:
 $   write sys$output "Required privs: SYSNAM, SYSPRV"
 $   status = 36
 $   goto exit
 $!...
 $exit:
 $   set process/privilege=(nosysnam,nosysprv)
   
 

 $   exit status + (0 * f$verify (old_verify))
|
   
 

Is there any clever way that the following features could work with
this kind of code?
   
 

1) dap (delete a paragraph): this currently deletes the whole source
file - because there are no empty lines between paragraphs (an "empty"
line must contain at least the $)
   
 

2)>>  (indent a line): this indents the leading $ as well as the rest
of the line; instead, the dollar should stay in column 1, and only the
rest of the line should be indented
   
 

3) J (join lines); gqq (format the line): if multiple lines become one
line, or vice versa, the dollars are not removed/inserted as they
should be
   
 

What I have come up with so far is using 'comments':
 :set comments=:$
This at least puts the $ sign on each new line.
   

I suppose you could have a pair of maps; one of which removes all the
leading "$"s, and the other would put them back:

map  :%s/^\$//e
map  :%s/^/$/e

Furthermore, you could automate this if you're confident enough in their
effects:

au BufRead  * if&ft =~ "dcl" | :%s/^\$//e|endif
au  BufWrite * if&ft =~ "dcl"|:s/^/$/e|endif

You might wish to put these into a .vim/ftplugin/dcl.vim file (I'd have
to guess at the actual OpenVMS directory, perhaps
[wherever.vimfiles.ftplugin]dcl.vim ?).

Of course, these are untested.

Regards,
Chip Campbell
 

Samuel Ferencik wrote:
   

Hi Chip,

thanks for the suggestion. Unfortunately, this will not work because
of line
continuations, which look like this:

 $ write sys$output "some text ", "more text ", -
   "even more text ", -
   "and yet more"
 $ write sys$output "next bit"

In other words, there may be lines with no leading $s. The
mapping would
tend to put "back" the leading $s even on lines which did not have it
in the
first place (lines 2 and 3 above).

Line continuations, i.e. lines with no leading $, are always preceded
by a line
ending with a "-" (hyphen), as seen in the example above. One could
rely on
this, perhaps, to detect that lines 2 and 3 in the excerpt above
should get no
leading dollar. However, I think you can have lines ending with a
hyphen, which
do not mean a line continuation, so this would not work either. (I am
not
totally convinced about this, but I seem to remember something like
that.)

But your idea is exactly what I am thinking: if only vim could somehow
ignore
the leading $, ignore that it is there, and process all commands as if
the
dollar was not there...

Thanks,
Sam
 
(the custom on this list is to bottom post so as to allow multiple 
responses to make sense)


Hello:

I think that the line continuation stuff could be handled:  try using 
the following BufWrite instead of the one given above:


au  BufWrite * if&ft =~ "dcl"|g/[^\-]$/.+1s/^/$/|1s/^/$/|endif

Of course, with these two autocmds you'd have to get used to working without 
seeing those $s...

Regards,
Chip Campbell




--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-21 Fir de Conversatie Samuel Ferencik
Ingo,

thanks a lot; both IndentCommentPrefix and CountJump seem very
promising. I will play with them.

Regards,
Sam

On Dec 20, 7:46 pm, Ingo Karkat  wrote:
> On 17-Dec-2010 22:17, Ingo Karkat wrote:
>
>
>
> > On 17-Dec-2010 21:24, Samuel Ferencik wrote:
> >> Hi,
>
> >> DCL is a scripting language for OpenVMS, whose lines of code must all 
> >> start with
> >> a $.
> > (...)
> >> Is there any clever way that the following features could work with this 
> >> kind of
> >> code?
>
> >> 1) dap (delete a paragraph): this currently deletes the whole source file -
> >> because there are no empty lines between paragraphs (an "empty" line must
> >> contain at least the $)
>
> > You'd have to (over-)write the "a paragraph" text object in Vimscript. 
> > There are
> > a few libraries that help with that. Incidentally, I have written one, 
> > CountJump.
> >    http://www.vim.org/scripts/script.php?script_id=3130
> > I wish I could include a line that would magically invoke the script to 
> > just do
> > what you need, but it's not yet that trivial. However, I do have a use case
> > quite similar to DCL, and once I get to implement that, it should be one 
> > line.
> > But also have a look at the other scripts referenced on the plugin page; 
> > maybe
> > one of those is a better fit.
>
> I sat down and implemented the missing bits. With the just released CountJump
> version 1.40, you should be able to define section motions ]], ][, [[ and [] 
> via:
>
> call CountJump#Region#Motion#MakeBracketMotion( '', '', '', 
> '^\$\s*\S', 1)
>
> and overwrite the inner/outer paragraph text objects via:
>
> call CountJump#Region#TextObject#Make( '', 'p', 'ai', 'V', 
> '^\$\s*\S', 1 )
>
> Both of these assume that lines containing just "$" followed by whitespace do
> not belong to a paragraph.
>
> I hope this helps!
>
> -- regards, ingo

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-21 Fir de Conversatie Samuel Ferencik
Hi Chip,

thanks for the suggestion. Unfortunately, this will not work because
of line
continuations, which look like this:

$ write sys$output "some text ", "more text ", -
  "even more text ", -
  "and yet more"
$ write sys$output "next bit"

In other words, there may be lines with no leading $s. The 
mapping would
tend to put "back" the leading $s even on lines which did not have it
in the
first place (lines 2 and 3 above).

Line continuations, i.e. lines with no leading $, are always preceded
by a line
ending with a "-" (hyphen), as seen in the example above. One could
rely on
this, perhaps, to detect that lines 2 and 3 in the excerpt above
should get no
leading dollar. However, I think you can have lines ending with a
hyphen, which
do not mean a line continuation, so this would not work either. (I am
not
totally convinced about this, but I seem to remember something like
that.)

But your idea is exactly what I am thinking: if only vim could somehow
ignore
the leading $, ignore that it is there, and process all commands as if
the
dollar was not there...

Thanks,
Sam

On Dec 18, 3:58 am, Charles E Campbell Jr 
wrote:
> Samuel Ferencik wrote:
> > Hi,
>
> > DCL is a scripting language for OpenVMS, whose lines of code must all
> > start with a $.
>
> > Here is a code excerpt (from
> >http://www.eight-cubed.com/articles/dcl_standards.html):
>
> > |        ||$       on warning then goto nopriv
> >         $       set on
> >         $       set process/privilege=(sysnam,sysprv)
> >         $!...
>
> >         $nopriv:
> >         $       write sys$output "Required privs: SYSNAM, SYSPRV"
> >         $       status = 36
> >         $       goto exit
> >         $!...
> >         $exit:
> >         $       set process/privilege=(nosysnam,nosysprv)
>
> >         $       exit status + (0 * f$verify (old_verify))
> > |
>
> > Is there any clever way that the following features could work with
> > this kind of code?
>
> > 1) dap (delete a paragraph): this currently deletes the whole source
> > file - because there are no empty lines between paragraphs (an "empty"
> > line must contain at least the $)
>
> > 2) >> (indent a line): this indents the leading $ as well as the rest
> > of the line; instead, the dollar should stay in column 1, and only the
> > rest of the line should be indented
>
> > 3) J (join lines); gqq (format the line): if multiple lines become one
> > line, or vice versa, the dollars are not removed/inserted as they
> > should be
>
> > What I have come up with so far is using 'comments':
> >     :set comments=:$
> > This at least puts the $ sign on each new line.
>
> I suppose you could have a pair of maps; one of which removes all the
> leading "$"s, and the other would put them back:
>
> map  :%s/^\$//e
> map  :%s/^/$/e
>
> Furthermore, you could automate this if you're confident enough in their
> effects:
>
> au BufRead  * if &ft =~ "dcl" | :%s/^\$//e|endif
> au  BufWrite * if &ft =~ "dcl"|:s/^/$/e|endif
>
> You might wish to put these into a .vim/ftplugin/dcl.vim file (I'd have
> to guess at the actual OpenVMS directory, perhaps
> [wherever.vimfiles.ftplugin]dcl.vim ?).
>
> Of course, these are untested.
>
> Regards,
> Chip Campbell

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-20 Fir de Conversatie Ingo Karkat
On 17-Dec-2010 22:17, Ingo Karkat wrote:
> On 17-Dec-2010 21:24, Samuel Ferencik wrote:
>> Hi,
>>
>> DCL is a scripting language for OpenVMS, whose lines of code must all start 
>> with
>> a $.
> (...)
>> Is there any clever way that the following features could work with this 
>> kind of
>> code?
>>
>> 1) dap (delete a paragraph): this currently deletes the whole source file -
>> because there are no empty lines between paragraphs (an "empty" line must
>> contain at least the $)
> 
> You'd have to (over-)write the "a paragraph" text object in Vimscript. There 
> are
> a few libraries that help with that. Incidentally, I have written one, 
> CountJump.
> http://www.vim.org/scripts/script.php?script_id=3130
> I wish I could include a line that would magically invoke the script to just 
> do
> what you need, but it's not yet that trivial. However, I do have a use case
> quite similar to DCL, and once I get to implement that, it should be one line.
> But also have a look at the other scripts referenced on the plugin page; maybe
> one of those is a better fit.

I sat down and implemented the missing bits. With the just released CountJump
version 1.40, you should be able to define section motions ]], ][, [[ and [] 
via:

call CountJump#Region#Motion#MakeBracketMotion( '', '', '', '^\$\s*\S', 
1)

and overwrite the inner/outer paragraph text objects via:

call CountJump#Region#TextObject#Make( '', 'p', 'ai', 'V', '^\$\s*\S', 
1 )

Both of these assume that lines containing just "$" followed by whitespace do
not belong to a paragraph.

I hope this helps!

-- regards, ingo

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-17 Fir de Conversatie Charles E Campbell Jr

Samuel Ferencik wrote:

Hi,

DCL is a scripting language for OpenVMS, whose lines of code must all 
start with a $.


Here is a code excerpt (from 
http://www.eight-cubed.com/articles/dcl_standards.html):


|||$   on warning then goto nopriv
$   set on
$   set process/privilege=(sysnam,sysprv)
$!...


$nopriv:
$   write sys$output "Required privs: SYSNAM, SYSPRV"
$   status = 36
$   goto exit
$!...
$exit:
$   set process/privilege=(nosysnam,nosysprv)


$   exit status + (0 * f$verify (old_verify))
|

Is there any clever way that the following features could work with 
this kind of code?


1) dap (delete a paragraph): this currently deletes the whole source 
file - because there are no empty lines between paragraphs (an "empty" 
line must contain at least the $)


2) >> (indent a line): this indents the leading $ as well as the rest 
of the line; instead, the dollar should stay in column 1, and only the 
rest of the line should be indented


3) J (join lines); gqq (format the line): if multiple lines become one 
line, or vice versa, the dollars are not removed/inserted as they 
should be


What I have come up with so far is using 'comments':
:set comments=:$
This at least puts the $ sign on each new line.
I suppose you could have a pair of maps; one of which removes all the 
leading "$"s, and the other would put them back:


map  :%s/^\$//e
map  :%s/^/$/e

Furthermore, you could automate this if you're confident enough in their 
effects:


au BufRead  * if &ft =~ "dcl" | :%s/^\$//e|endif
au  BufWrite * if &ft =~ "dcl"|:s/^/$/e|endif

You might wish to put these into a .vim/ftplugin/dcl.vim file (I'd have 
to guess at the actual OpenVMS directory, perhaps 
[wherever.vimfiles.ftplugin]dcl.vim ?).


Of course, these are untested.

Regards,
Chip Campbell

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: editing DCL

2010-12-17 Fir de Conversatie Ingo Karkat
On 17-Dec-2010 21:24, Samuel Ferencik wrote:
> Hi,
> 
> DCL is a scripting language for OpenVMS, whose lines of code must all start 
> with
> a $.
(...)
> Is there any clever way that the following features could work with this kind 
> of
> code?
> 
> 1) dap (delete a paragraph): this currently deletes the whole source file -
> because there are no empty lines between paragraphs (an "empty" line must
> contain at least the $)

You'd have to (over-)write the "a paragraph" text object in Vimscript. There are
a few libraries that help with that. Incidentally, I have written one, 
CountJump.
http://www.vim.org/scripts/script.php?script_id=3130
I wish I could include a line that would magically invoke the script to just do
what you need, but it's not yet that trivial. However, I do have a use case
quite similar to DCL, and once I get to implement that, it should be one line.
But also have a look at the other scripts referenced on the plugin page; maybe
one of those is a better fit.

> 2) >> (indent a line): this indents the leading $ as well as the rest of the
> line; instead, the dollar should stay in column 1, and only the rest of the 
> line
> should be indented

I have written IndentCommentPrefix for exactly that purpose:
http://www.vim.org/scripts/script.php?script_id=2529
It just requires that you properly :set comments; which you've already done.

> 3) J (join lines); gqq (format the line): if multiple lines become one line, 
> or
> vice versa, the dollars are not removed/inserted as they should be

For joining, you could put something like this into .vim/ftplugin/dcl.vim
(assuming you have a filetype detection or :setf dcl manually):

nnoremap   J Jc/\%# \?\$[ \t]\+\ze\w/e ciw 

I don't know how you would want to react to lines that start with labels and
those "!..." directives(?); you may want to tweak the regexp to suit DCL.

> What I have come up with so far is using 'comments':
> :set comments=:$
> This at least puts the $ sign on each new line.

Good start, and good luck!

-- regards, ingo
-- 
  -- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
  --  http://vim.sourceforge.net/account/profile.php?user_id=9713--

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


editing DCL

2010-12-17 Fir de Conversatie Samuel Ferencik
Hi,

DCL is a scripting language for OpenVMS, whose lines of code must all start
with a $.

Here is a code excerpt (from
http://www.eight-cubed.com/articles/dcl_standards.html):

$   on warning then goto nopriv
$   set on
$   set process/privilege=(sysnam,sysprv)
$!...

$nopriv:
$   write sys$output "Required privs: SYSNAM, SYSPRV"
$   status = 36
$   goto exit
$!...
$exit:
$   set process/privilege=(nosysnam,nosysprv)

$   exit status + (0 * f$verify (old_verify))


Is there any clever way that the following features could work with this
kind of code?

1) dap (delete a paragraph): this currently deletes the whole source file -
because there are no empty lines between paragraphs (an "empty" line must
contain at least the $)

2) >> (indent a line): this indents the leading $ as well as the rest of the
line; instead, the dollar should stay in column 1, and only the rest of the
line should be indented

3) J (join lines); gqq (format the line): if multiple lines become one line,
or vice versa, the dollars are not removed/inserted as they should be

What I have come up with so far is using 'comments':
:set comments=:$
This at least puts the $ sign on each new line.

Any other tricks/ideas would be appreciated. Is there another such language
that requires leading chars?

Sam

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php