an old "hack" of mine, shared for amusement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

an old "hack" of mine, shared for amusement

Elijah Griffin
I found this today, while looking for abandoned swap files on my
computer. The file was dated 2006, but the swap file is for vim 4.2,
and the hostname is one I last used ~ 1998. I guess I copied the
file, and the swap file, from a backup or something in 2006.

  $ ls -l my-src/hacks/vi/fork my-src/hacks/vi/fork.swp
  -rw-r--r-- 1 elijah users    58 Jun  6  2006 my-src/hacks/vi/fork
  -rw-r--r-- 1 elijah users 24576 Jun  6  2006 my-src/hacks/vi/fork.swp
  $ cat my-src/hacks/vi/fork
  vi: set noml | w! | ! vim % :
  vi: e! % | w! | q :

  foobar
  $

I don't remember writing that, but I can fully believe I did. (There's
other stuff there, I'm sure I have written.

What this does is left as an exercise for the reader.

I suspect I tested it on Solaris vi of that era. Testing in Solaris vi
(Version SVR4.0, Solaris 2.5.0) today[*], I need to hit <esc> to
unstick-it at a certain point, and I think the second line would be
better as just:

  vi: q :

Elijah
------
[*] only has one, rather old, Solaris system left to test with

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Erik Christiansen
On 24.04.17 19:50, Eli the Bearded wrote:

>   $ cat my-src/hacks/vi/fork
>   vi: set noml | w! | ! vim % :
>   vi: e! % | w! | q :
>
>   foobar
>   $
>
> I don't remember writing that, but I can fully believe I did. (There's
> other stuff there, I'm sure I have written.
>
> What this does is left as an exercise for the reader.

That is most interesting, as ":h modeline" describes that they comprise only
"set" directives, not arbitrary commands. I.e.:

{options}               a list of option settings, separated with white space
                        or ':', where each part between ':' is the argument
                        for a ":set" command (can be empty)

after the:

{vi:|vim:|ex:}          the string "vi:", "vim:" or "ex:"

It doesn't even allow the '|'.

How turning off modelines might help to execute commands in modelines is
a guessing game, without documentation of supported behaviour.

Admittedly, on the few occasions that an arbitrary command seemed to be
needed, I've found another way to achieve the result.

Erik

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Erik Falor
On Tue, Apr 25, 2017 at 01:40:52PM +1000, Erik Christiansen wrote:

> On 24.04.17 19:50, Eli the Bearded wrote:
> > What this does is left as an exercise for the reader.
>
> That is most interesting, as ":h modeline" describes that they comprise only
> "set" directives, not arbitrary commands. I.e.:
>
> {options}               a list of option settings, separated with white space
>                         or ':', where each part between ':' is the argument
>                         for a ":set" command (can be empty)
>
> after the:
>
> {vi:|vim:|ex:}          the string "vi:", "vim:" or "ex:"
>
> It doesn't even allow the '|'.
>
> How turning off modelines might help to execute commands in modelines is
> a guessing game, without documentation of supported behaviour.
>
> Admittedly, on the few occasions that an arbitrary command seemed to be
> needed, I've found another way to achieve the result.
Eli did mention that he had been running Vim version 4.2. Perhaps
modelines worked differently back then?

The oldest Vim source code I could find in a brief search is version
6.4. Does anybody know of a way to find a version that's even older
than that?

--
Erik Falor
Registered Linux User #445632                    http://unnovative.net

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Christian Brabandt
On Mo, 24 Apr 2017, Erik Falor wrote:

> Eli did mention that he had been running Vim version 4.2. Perhaps
> modelines worked differently back then?
>
> The oldest Vim source code I could find in a brief search is version
> 6.4. Does anybody know of a way to find a version that's even older
> than that?

A while ago, I converted the old Vim CVS Repository to git and I made it
available here:
https://bitbucket.org/vim-mirror/vim-ancient

#v+
~/vim-ancient$ git log --reverse |head -15
commit 686757e4d2a46c8ab55c08c7a0ccd9d83d2465fb
Author: Bram Moolenaar <[hidden email]>
Date:   Sun Dec 19 03:43:45 1999 +0000

    Initial revision

commit d8a836d4df71284a494011056263b98972ae6823
Author: Bram Moolenaar <[hidden email]>
Date:   Sun Dec 19 03:50:09 1999 +0000

    Patch 5.5.001
    Problem:    Configure in the top directory did not pass on an argument with a
                space correctly.  For example "./configure --previs="/My home".
                (Stephane Chazelas)
    Solution:   Use '"$@"' instead of '$*' to pass on the arguments.
#v-


Best,
Christian
--
Es gibt zwei Arten von Menschen: Solche die Gl├╝ck haben und solche wie mich.

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Erik Falor
On Tue, Apr 25, 2017 at 09:16:54AM +0200, Christian Brabandt wrote:

>
> A while ago, I converted the old Vim CVS Repository to git and I made it
> available here:
> https://bitbucket.org/vim-mirror/vim-ancient
>
> #v+
> ~/vim-ancient$ git log --reverse |head -15
> commit 686757e4d2a46c8ab55c08c7a0ccd9d83d2465fb
> Author: Bram Moolenaar <[hidden email]>
> Date:   Sun Dec 19 03:43:45 1999 +0000
>
>     Initial revision
I can report that this "hack" doesn't do anything interesting as of Vim 5.5.
It doesn't complain about the pipe characters in the modelines, though.

:version
VIM - Vi IMproved 5.5 (1999 Sep 19)
Compiled by fadein@viking2, with (+) or without (-):
+autocmd -browse ++builtin_terms +byte_offset +cindent +cmdline_compl +cmdline_info +comments +cryptv +cscope
+dialog_con +digraphs +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path -osfiletype +find_in_path +fork()
-GUI -hangul_input +insert_expand +langmap +linebreak +lispindent +menu +mksession +modify_fname +mouse +mouse_dec
-mouse_gpm +mouse_netterm +mouse_xterm +multi_byte -perl +quickfix -python +rightleft +scrollbind +smartindent -sniff
+statusline +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +textobjects +title +user_commands
+visualextra +viminfo +wildignore +wildmenu +writebackup -X11 -xfontset -xim -xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H    -g -O2 -Wall
Linking: gcc  -o vim         -lncurses

--
Erik Falor
Registered Linux User #445632                    http://unnovative.net

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Elijah Griffin

Erik Falor wrote:
> I can report that this "hack" doesn't do anything interesting as of Vim 5.5.
> It doesn't complain about the pipe characters in the modelines, though.

Everyone seems to be missing it. rot13 solution for those interested.

Guvf *unpx* jnf qrfvtarq gb *abg* jbex va ivz.

Vg jbexf va iv. Vg znxrf iv erbcra gur svyr jvgu ivz.

(And by-the-by, I have Vim 3.0 for Mac System 7. I found it for download
last year when I was playing with the Basilisk II emulator. Vim 3: back
when 'q' did the thing 'gq' does now. And 'Q' was unimplemented.)

Elijah
------
http://wayback.archive.org/web/19990422231919/http://www.qz.to/~eli/src/modeline.html

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Christian Brabandt
Hi Eli!

On Di, 25 Apr 2017, Eli the Bearded wrote:

> Everyone seems to be missing it. rot13 solution for those interested.
>
> This *hack* was designed to *not* work in vim.
>
> It works in vi. It makes vi reopen the file with vim.
>
> (And by-the-by, I have Vim 3.0 for Mac System 7. I found it for download
> last year when I was playing with the Basilisk II emulator. Vim 3: back
> when 'q' did the thing 'gq' does now. And 'Q' was unimplemented.)

Are you saying, original Vi could be tricked to execute various commands
via modelines? That sounds pretty scary actually.

Best,
Christian
--
Ein kluger Mann widerspricht nie einer Frau. Er wartet, bis sie es
selbst tut.
                -- Humphrey Bogart

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Elijah Griffin
Christian Brabandt wrote:
> Are you saying, original Vi could be tricked to execute various commands
> via modelines? That sounds pretty scary actually.

Still can, if you have real vi somewhere. (You can also embed arbitrary
ex commands in tag files for real vi.)

Elijah

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: an old "hack" of mine, shared for amusement

Erik Falor
On Tue, Apr 25, 2017 at 04:23:12PM -0400, Eli the Bearded wrote:
> Christian Brabandt wrote:
> > Are you saying, original Vi could be tricked to execute various commands
> > via modelines? That sounds pretty scary actually.
>
> Still can, if you have real vi somewhere. (You can also embed arbitrary
> ex commands in tag files for real vi.)

I will say in my defense that the clue about the Vim 4.2 swap file was
a bit of a red herring, especially since Vim honors ex and vi's
modelines.

Anyhow, it's now time to test this with Traditional Vi

http://ex-vi.sourceforge.net/

--
Erik Falor
Registered Linux User #445632                    http://unnovative.net

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (169 bytes) Download Attachment