Loading ...
Sorry, an error occurred while loading the content.
 

Simple printing "patch" for MacVim

Expand Messages
  • Nico Weber
    Hi all, I was using a samba printer last weekend. The printer worked fine in all applications that had a real printing dialog, but it didn t work from within
    Message 1 of 26 , Jun 27, 2008
      Hi all,

      I was using a samba printer last weekend. The printer worked fine in
      all applications that had a "real" printing dialog, but it didn't work
      from within MacVim (`lpr` wasn't working either). So I started to work
      on a patch to add printing support to MacVim. Since both vim's code
      for `:hardcopy` and Cocoa's printing mechanism expect you to provide a
      set of callbacks that essentially do things like "draw page <n>", this
      is not that trivial (for example, vim calls
      `mch_print_begin(prt_settings_T*)` and expects this function to ask
      the user for a printer, paper size, etc and return that information to
      vim, while Cocoa's `-[NSPrintOperation runOperation]` does not return
      until printing is done).

      Long story short, MacVim's printing is "good enough" for me with the
      following setting:

      set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\
      delete(v:fname_in)\ +\ v:shell_error

      With this setting, the file is printed to a ps, which is then opened
      in Preview (which does have a Cocoa print dialog). Should this option
      be included in MacVim's system vimrc? This changes both the behaviour
      of `:hardcopy` and ⌘P (which is bound to `:hardcopy`).

      Nico
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Nico Weber
      ... This is supposed to be one line. The `delete` part should probably be left out, sometimes the ps file is deleted before Preview can convert it (this
      Message 2 of 26 , Jun 27, 2008
        On 27.06.2008, at 14:05, Nico Weber wrote:

        > Long story short, MacVim's printing is "good enough" for me with the
        > following setting:
        >
        > set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\
        > delete(v:fname_in)\ +\ v:shell_error

        This is supposed to be one line. The `delete` part should probably be
        left out, sometimes the ps file is deleted before Preview can convert
        it (this litters /private/var/folders/.../-Tmp-/, but that directory
        is hopefully periodically cleaned anyway). Furthermore, this does not
        support printing of non-ASCII text, and long lines are wrapped in the
        middle of words ('linebreak' is ignored when printing (see `:h
        printing`), and 'printoptions' does not support something like
        'linebreak'). So this really is only a "good enough" solution. It's in
        my eyes better than the current behavior, though.

        Nico

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Matt Tolton
        ... I tried this out and it s really nice. I did have to get rid of the delete() part to make it work. One solution to this would be to add sleep 60; rm
        Message 3 of 26 , Jun 27, 2008
          >> set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\
          >> delete(v:fname_in)\ +\ v:shell_error

          I tried this out and it's really nice. I did have to get rid of the
          delete() part to make it work. One solution to this would be to add
          'sleep 60; rm v:fname_in' to the system() call and background the
          entire thing.

          Either way, I agree that this should be added to the macvim gvimrc.

          Matt

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • björn
          ... It works for me without the delete() part as well. I don t mind including something like this in $SYS/gvimrc, but what should we do about the delete ?
          Message 4 of 26 , Jun 27, 2008
            2008/6/27 Matt Tolton <matt@...>:
            >
            >>> set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\
            >>> delete(v:fname_in)\ +\ v:shell_error
            >
            > I tried this out and it's really nice. I did have to get rid of the
            > delete() part to make it work. One solution to this would be to add
            > 'sleep 60; rm v:fname_in' to the system() call and background the
            > entire thing.
            >
            > Either way, I agree that this should be added to the macvim gvimrc.

            It works for me without the delete() part as well. I don't mind
            including something like this in $SYS/gvimrc, but what should we do
            about the "delete"?

            Björn

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Matt Tolton
            ... Well...I suggested a solution in my last response. :) It would also probably be ok to just drop the delete like Nico suggested. Matt
            Message 5 of 26 , Jun 27, 2008
              > It works for me without the delete() part as well. I don't mind
              > including something like this in $SYS/gvimrc, but what should we do
              > about the "delete"?

              Well...I suggested a solution in my last response. :) It would also
              probably be ok to just drop the delete like Nico suggested.

              Matt

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • björn
              ... So, should I just add this line to $SYS/gvimrc: set printexpr=system( open -a Preview .v:fname_in) . + v:shell_error Or, should I change it in the
              Message 6 of 26 , Jul 1 12:14 PM
                2008/6/28 Matt Tolton <matt@...>:
                >
                >> It works for me without the delete() part as well. I don't mind
                >> including something like this in $SYS/gvimrc, but what should we do
                >> about the "delete"?
                >
                > Well...I suggested a solution in my last response. :) It would also
                > probably be ok to just drop the delete like Nico suggested.

                So, should I just add this line to $SYS/gvimrc:

                set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\ +\ v:shell_error

                Or, should I change it in the source code? I don't understand the
                implications of not deleting the file afterwards, or how/if the
                delayed delete would work.

                Björn

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_mac" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Nico Weber
                Hi, ... set printexpr=system( open .v:fname_in) + v:shell_error (without the . at the end). ... I d add it to $SYS/gvimrc. I m not sure what happens if
                Message 7 of 26 , Jul 1 3:28 PM
                  Hi,

                  >>> It works for me without the delete() part as well. I don't mind
                  >>> including something like this in $SYS/gvimrc, but what should we do
                  >>> about the "delete"?
                  >>
                  >> Well...I suggested a solution in my last response. :) It would also
                  >> probably be ok to just drop the delete like Nico suggested.
                  >
                  > So, should I just add this line to $SYS/gvimrc:
                  >
                  > set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ .\ +\
                  > v:shell_error

                  set printexpr=system('open\ '.v:fname_in)\ +\ v:shell_error
                  (without the '.' at the end).

                  >
                  >
                  > Or, should I change it in the source code? I don't understand the
                  > implications of not deleting the file afterwards, or how/if the
                  > delayed delete would work.

                  I'd add it to $SYS/gvimrc. I'm not sure what happens if the file is
                  not deleted, I guess it is deleted when you reboot your computer (the
                  temporary file was created in a subdir in /private/var/folders/. I
                  have since rebooted my Mac, and now it's gone).

                  Nico

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_mac" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Steven Michalske
                  automator to the rescue --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_mac maillist. For more information,
                  Message 8 of 26 , Jul 1 3:54 PM
                    automator to the rescue


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_mac" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • björn
                    ... That s a pretty neat idea too. I m guessing most people would expect a print dialog box though (I would) so in that sense I think Nico s idea is slightly
                    Message 9 of 26 , Jul 2 1:08 PM
                      2008/7/2 Steven Michalske <smichalske@...>:
                      > automator to the rescue
                      >
                      > then you would set the printing command to:
                      >
                      > automator -i FILE_NAME_HERE ~/Documents/printToOreo.workflow
                      >
                      > here in automator.app I set it to my preferred printer, your other
                      > option is to use the default printer.
                      >
                      > it wont show a print dialog box.... but it works.

                      That's a pretty neat idea too. I'm guessing most people would expect
                      a print dialog box though (I would) so in that sense I think Nico's
                      idea is slightly better. What do other people think?

                      Björn

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_mac" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Nico Weber
                      ... I prefer opening the file in Preview. As far as I understand the automator action does not give any visual feedback (?), which is confusing to me. Nico
                      Message 10 of 26 , Jul 2 1:43 PM
                        >> automator to the rescue
                        >>
                        >> then you would set the printing command to:
                        >>
                        >> automator -i FILE_NAME_HERE ~/Documents/printToOreo.workflow
                        >>
                        >> here in automator.app I set it to my preferred printer, your other
                        >> option is to use the default printer.
                        >>
                        >> it wont show a print dialog box.... but it works.
                        >
                        > That's a pretty neat idea too. I'm guessing most people would expect
                        > a print dialog box though (I would) so in that sense I think Nico's
                        > idea is slightly better. What do other people think?

                        I prefer opening the file in Preview. As far as I understand the
                        automator action does not give any visual feedback (?), which is
                        confusing to me.

                        Nico

                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_mac" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Matt Tolton
                        ... I also prefer opening the file in preview. --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_mac maillist. For
                        Message 11 of 26 , Jul 2 2:39 PM
                          >> That's a pretty neat idea too. I'm guessing most people would expect
                          >> a print dialog box though (I would) so in that sense I think Nico's
                          >> idea is slightly better. What do other people think?
                          >
                          > I prefer opening the file in Preview. As far as I understand the
                          > automator action does not give any visual feedback (?), which is
                          > confusing to me.

                          I also prefer opening the file in preview.

                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_mac" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • Steven Michalske
                          under the print finder items action s options you can turn on show this action check box. This will put a simple dialog box on the screen with the option to
                          Message 12 of 26 , Jul 2 10:25 PM
                            under the print finder items action's options you can turn on show
                            this action check box.

                            This will put a simple dialog box on the screen with the option to
                            select the printer.

                            With hardcopy on my linux installs I don't get feedback..... it just
                            prints.....

                            to monitor status of large jobs, the printer dialog box will be in
                            your dock till the job is sent to the printer.

                            :-)

                            hardkrash

                            On Jul 2, 2008, at 1:43 PM, Nico Weber wrote:

                            >
                            >>> automator to the rescue
                            >>>
                            >>> then you would set the printing command to:
                            >>>
                            >>> automator -i FILE_NAME_HERE ~/Documents/printToOreo.workflow
                            >>>
                            >>> here in automator.app I set it to my preferred printer, your other
                            >>> option is to use the default printer.
                            >>>
                            >>> it wont show a print dialog box.... but it works.
                            >>
                            >> That's a pretty neat idea too. I'm guessing most people would expect
                            >> a print dialog box though (I would) so in that sense I think Nico's
                            >> idea is slightly better. What do other people think?
                            >
                            > I prefer opening the file in Preview. As far as I understand the
                            > automator action does not give any visual feedback (?), which is
                            > confusing to me.
                            >
                            > Nico
                            >
                            > >


                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_mac" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          • Steven Michalske
                            install the workfolw to ~/.vim and set this printexpr=system( automator -i .v:fname_in. ~/.vim/print.workflow ) edit the workflow s options for the option
                            Message 13 of 26 , Jul 2 10:42 PM
                              install the workfolw to ~/.vim

                              and set this

                              printexpr=system('automator\ -i\ '.v:fname_in.'\ ~/.vim/print.workflow')

                              edit the workflow's options for the option for it to ask you for which
                              printer to use.

                              hardkrash

                              On Jul 2, 2008, at 10:25 PM, Steven Michalske wrote:

                              > under the print finder items action's options you can turn on show
                              > this action check box.
                              >
                              > This will put a simple dialog box on the screen with the option to
                              > select the printer.
                              >
                              > With hardcopy on my linux installs I don't get feedback..... it
                              > just prints.....
                              >
                              > to monitor status of large jobs, the printer dialog box will be in
                              > your dock till the job is sent to the printer.
                              >
                              > :-)
                              >
                              > hardkrash
                              >
                              > On Jul 2, 2008, at 1:43 PM, Nico Weber wrote:
                              >
                              >>
                              >>>> automator to the rescue
                              >>>>
                              >>>> then you would set the printing command to:
                              >>>>
                              >>>> automator -i FILE_NAME_HERE ~/Documents/printToOreo.workflow
                              >>>>
                              >>>> here in automator.app I set it to my preferred printer, your other
                              >>>> option is to use the default printer.
                              >>>>
                              >>>> it wont show a print dialog box.... but it works.
                              >>>
                              >>> That's a pretty neat idea too. I'm guessing most people would
                              >>> expect
                              >>> a print dialog box though (I would) so in that sense I think Nico's
                              >>> idea is slightly better. What do other people think?
                              >>
                              >> I prefer opening the file in Preview. As far as I understand the
                              >> automator action does not give any visual feedback (?), which is
                              >> confusing to me.
                              >>
                              >> Nico
                              >>
                              >> >>
                              >


                              --~--~---------~--~----~------------~-------~--~----~
                              You received this message from the "vim_mac" maillist.
                              For more information, visit http://www.vim.org/maillist.php
                              -~----------~----~----~----~------~----~------~--~---
                            • björn
                              ... That is much better, but I still prefer being able to see the file to be printed in Preview first. Attached is a patch that builds on both Nico s and
                              Message 14 of 26 , Jul 3 1:13 PM
                                2008/7/3 Steven Michalske <smichalske@...>:
                                >
                                > install the workfolw to ~/.vim
                                >
                                > and set this
                                >
                                > printexpr=system('automator\ -i\ '.v:fname_in.'\ ~/.vim/print.workflow')
                                >
                                > edit the workflow's options for the option for it to ask you for which
                                > printer to use.

                                That is much better, but I still prefer being able to see the file to
                                be printed in Preview first. Attached is a patch that builds on both
                                Nico's and Steven's ideas. Automator is used to open the file from
                                :hardcopy in Preview, then the it deletes the temporary file.

                                Two nuisances:

                                1. Preview doesn't always get the focus
                                2. When quitting Preview you get a dialog box asking if you want to
                                save the pdf since it converted the ps that :hardcopy generated

                                Can somebody please test the attached patch before I merge this into
                                the public repo?

                                Thanks,
                                Björn

                                --~--~---------~--~----~------------~-------~--~----~
                                You received this message from the "vim_mac" maillist.
                                For more information, visit http://www.vim.org/maillist.php
                                -~----------~----~----~----~------~----~------~--~---
                              • Nico Weber
                                Hi, ... (2.) happens with the system( open ) call as well. ... Seems to work over here. Does the automator action guarantee that Open Finder Items does not
                                Message 15 of 26 , Jul 3 2:31 PM
                                  Hi,

                                  > Two nuisances:
                                  >
                                  > 1. Preview doesn't always get the focus
                                  > 2. When quitting Preview you get a dialog box asking if you want to
                                  > save the pdf since it converted the ps that :hardcopy generated

                                  (2.) happens with the system('open') call as well.

                                  > Can somebody please test the attached patch before I merge this into
                                  > the public repo?

                                  Seems to work over here. Does the automator action guarantee that
                                  "Open Finder Items" does not return until the file is opened? If not,
                                  this has the same problem as using system('open') and then deleting
                                  the file (with the difference that automator is several orders of
                                  magnitude slower, so that the problem is not observable). Hm, it works
                                  with a 82 pages document (6000 lines of 'aaaaaaaa'), so this is
                                  probably ok.

                                  >

                                  It's a bit sad that this has to be 5k what could be a 120 byte change.
                                  But who cares about 5k these days :-P

                                  Nico

                                  --~--~---------~--~----~------------~-------~--~----~
                                  You received this message from the "vim_mac" maillist.
                                  For more information, visit http://www.vim.org/maillist.php
                                  -~----------~----~----~----~------~----~------~--~---
                                • Matt Tolton
                                  ... TBH, I think that the automator solution is more complex than necessary for this task. Why aren t we doing something like this: set
                                  Message 16 of 26 , Jul 3 4:11 PM
                                    > It's a bit sad that this has to be 5k what could be a 120 byte change.
                                    > But who cares about 5k these days :-P

                                    TBH, I think that the automator solution is more complex than
                                    necessary for this task. Why aren't we doing something like this:

                                    set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\ 60;rm\
                                    '.v:fname_in.')&')

                                    Matt

                                    --~--~---------~--~----~------------~-------~--~----~
                                    You received this message from the "vim_mac" maillist.
                                    For more information, visit http://www.vim.org/maillist.php
                                    -~----------~----~----~----~------~----~------~--~---
                                  • Frank Hellenkamp
                                    Hi, ... And what about: set printexpr=system( (ps2pdf .v:fname_in. .v:fname_in. .pdf;open -a Preview .v:fname_in. .pdf;sleep 60;rm
                                    Message 17 of 26 , Jul 3 10:55 PM
                                      Hi,

                                      >> It's a bit sad that this has to be 5k what could be a 120 byte change.
                                      >> But who cares about 5k these days :-P
                                      >
                                      > TBH, I think that the automator solution is more complex than
                                      > necessary for this task. Why aren't we doing something like this:
                                      >
                                      > set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\ 60;rm\
                                      > '.v:fname_in.')&')

                                      And what about:

                                      set printexpr=system('(ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf;open\
                                      -a\ Preview\ '.v:fname_in.'.pdf;sleep\ 60;rm\ '.v:fname_in.';rm\
                                      '.v:fname_in.'.pdf)&')

                                      It first converts the postscript to pdf, so you won't be asked to save
                                      the file.


                                      Frank

                                      --
                                      frank hellenkamp | interface designer
                                      jonas.info@... | mail
                                      +49.30.49 78 20 70 | tel
                                      +49.173.70 55 781 | mbl
                                      +49.1805.4002.243 912 | fax
                                    • Matt Tolton
                                      ... Don t you have to have ghostscript installed to have ps2pdf on your system? --~--~---------~--~----~------------~-------~--~----~ You received this message
                                      Message 18 of 26 , Jul 4 1:49 AM
                                        > set printexpr=system('(ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf;open\ -a\
                                        > Preview\ '.v:fname_in.'.pdf;sleep\ 60;rm\ '.v:fname_in.';rm\
                                        > '.v:fname_in.'.pdf)&')

                                        Don't you have to have ghostscript installed to have ps2pdf on your system?

                                        --~--~---------~--~----~------------~-------~--~----~
                                        You received this message from the "vim_mac" maillist.
                                        For more information, visit http://www.vim.org/maillist.php
                                        -~----------~----~----~----~------~----~------~--~---
                                      • Nico Weber
                                        ... That deletes the pdf after 60 seconds as well. I don t know if Preview is happy about that. Nico --~--~---------~--~----~------------~-------~--~----~ You
                                        Message 19 of 26 , Jul 4 1:55 AM
                                          >>> It's a bit sad that this has to be 5k what could be a 120 byte
                                          >>> change.
                                          >>> But who cares about 5k these days :-P
                                          >> TBH, I think that the automator solution is more complex than
                                          >> necessary for this task. Why aren't we doing something like this:
                                          >> set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\
                                          >> 60;rm\
                                          >> '.v:fname_in.')&')
                                          >
                                          > And what about:
                                          >
                                          > set printexpr=system('(ps2pdf\ '.v:fname_in.'\
                                          > '.v:fname_in.'.pdf;open\ -a\ Preview\ '.v:fname_in.'.pdf;sleep\ 60;rm
                                          > \ '.v:fname_in.';rm\ '.v:fname_in.'.pdf)&')
                                          >
                                          > It first converts the postscript to pdf, so you won't be asked to
                                          > save the file.

                                          That deletes the pdf after 60 seconds as well. I don't know if Preview
                                          is happy about that.

                                          Nico

                                          --~--~---------~--~----~------------~-------~--~----~
                                          You received this message from the "vim_mac" maillist.
                                          For more information, visit http://www.vim.org/maillist.php
                                          -~----------~----~----~----~------~----~------~--~---
                                        • Nico Weber
                                          ... This fails if Preview takes more than 60 seconds to open the file (entirely reasonable on my iBook when lots of other programs are open). The automator
                                          Message 20 of 26 , Jul 4 2:05 AM
                                            >> It's a bit sad that this has to be 5k what could be a 120 byte
                                            >> change.
                                            >> But who cares about 5k these days :-P
                                            >
                                            > TBH, I think that the automator solution is more complex than
                                            > necessary for this task. Why aren't we doing something like this:
                                            >
                                            > set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\ 60;rm\
                                            > '.v:fname_in.')&')

                                            This fails if Preview takes more than 60 seconds to open the file
                                            (entirely reasonable on my iBook when lots of other programs are
                                            open). The automator solution seems to work fine, and while it's a bit
                                            complex, it (seemingly) works reliably.

                                            Nico

                                            --~--~---------~--~----~------------~-------~--~----~
                                            You received this message from the "vim_mac" maillist.
                                            For more information, visit http://www.vim.org/maillist.php
                                            -~----------~----~----~----~------~----~------~--~---
                                          • Frank Hellenkamp
                                            ... I have a ps2pdf in /usr/bin/ so I *think* it s part of the system (I m not sure.) Have someone a clean system without that much fiddling, which I have done
                                            Message 21 of 26 , Jul 4 3:11 AM
                                              >> set printexpr=system('(ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf;open\ -a\
                                              >> Preview\ '.v:fname_in.'.pdf;sleep\ 60;rm\ '.v:fname_in.';rm\
                                              >> '.v:fname_in.'.pdf)&')
                                              >
                                              > Don't you have to have ghostscript installed to have ps2pdf on your system?

                                              I have a ps2pdf in /usr/bin/ so I *think* it's part of the system (I'm
                                              not sure.)

                                              Have someone a clean system without that much fiddling, which I have
                                              done with mine?

                                              I *have* an extra ghostscript install but it's in /opt/local/bin/,
                                              because it's a macports install.


                                              Frank

                                              --
                                              frank hellenkamp | interface designer
                                              jonas.info@... | mail
                                              +49.30.49 78 20 70 | tel
                                              +49.173.70 55 781 | mbl
                                              +49.1805.4002.243 912 | fax
                                            • Frank Hellenkamp
                                              ... The thing is, that the automator workflow in itself eats much resources, and thereof takes longer. The simpler scripting solution works much faster on my
                                              Message 22 of 26 , Jul 4 3:17 AM
                                                >>> It's a bit sad that this has to be 5k what could be a 120 byte
                                                >>> change.
                                                >>> But who cares about 5k these days :-P
                                                >> TBH, I think that the automator solution is more complex than
                                                >> necessary for this task. Why aren't we doing something like this:
                                                >>
                                                >> set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\ 60;rm\
                                                >> '.v:fname_in.')&')
                                                >
                                                > This fails if Preview takes more than 60 seconds to open the file
                                                > (entirely reasonable on my iBook when lots of other programs are
                                                > open). The automator solution seems to work fine, and while it's a bit
                                                > complex, it (seemingly) works reliably.

                                                The thing is, that the automator workflow in itself eats much resources,
                                                and thereof takes longer. The simpler scripting solution works much
                                                faster on my g4 powerbook, than the automator-solution.

                                                So it depends. We could wait much longer than 60 seconds, but sure, it
                                                is a hack, and you will have an extra process in the background for that
                                                time.


                                                Frank

                                                --
                                                frank hellenkamp | interface designer
                                                jonas.info@... | mail
                                                +49.30.49 78 20 70 | tel
                                                +49.173.70 55 781 | mbl
                                                +49.1805.4002.243 912 | fax
                                              • Frank Hellenkamp
                                                ... That won t be a problem, when the file is open. The actual file won t be removed from the filesystem until it s closed. Frank -- frank hellenkamp |
                                                Message 23 of 26 , Jul 4 3:18 AM
                                                  >>>> It's a bit sad that this has to be 5k what could be a 120 byte
                                                  >>>> change.
                                                  >>>> But who cares about 5k these days :-P
                                                  >>> TBH, I think that the automator solution is more complex than
                                                  >>> necessary for this task. Why aren't we doing something like this:
                                                  >>> set printexpr=system('(open\ -a\ Preview\ '.v:fname_in.';sleep\
                                                  >>> 60;rm\
                                                  >>> '.v:fname_in.')&')
                                                  >> And what about:
                                                  >>
                                                  >> set printexpr=system('(ps2pdf\ '.v:fname_in.'\
                                                  >> '.v:fname_in.'.pdf;open\ -a\ Preview\ '.v:fname_in.'.pdf;sleep\ 60;rm
                                                  >> \ '.v:fname_in.';rm\ '.v:fname_in.'.pdf)&')
                                                  >>
                                                  >> It first converts the postscript to pdf, so you won't be asked to
                                                  >> save the file.
                                                  >
                                                  > That deletes the pdf after 60 seconds as well. I don't know if Preview
                                                  > is happy about that.

                                                  That won't be a problem, when the file is open. The actual file won't be
                                                  removed from the filesystem until it's closed.


                                                  Frank

                                                  --
                                                  frank hellenkamp | interface designer
                                                  jonas.info@... | mail
                                                  +49.30.49 78 20 70 | tel
                                                  +49.173.70 55 781 | mbl
                                                  +49.1805.4002.243 912 | fax
                                                • Matt Tolton
                                                  ... Let s just not delete the file, then. It will be cleared after awhile, anyway. The automator solution is slower, and it is overkill.
                                                  Message 24 of 26 , Jul 4 11:32 AM
                                                    > This fails if Preview takes more than 60 seconds to open the file
                                                    > (entirely reasonable on my iBook when lots of other programs are
                                                    > open). The automator solution seems to work fine, and while it's a bit
                                                    > complex, it (seemingly) works reliably.

                                                    Let's just not delete the file, then. It will be cleared after
                                                    awhile, anyway. The automator solution is slower, and it is overkill.

                                                    --~--~---------~--~----~------------~-------~--~----~
                                                    You received this message from the "vim_mac" maillist.
                                                    For more information, visit http://www.vim.org/maillist.php
                                                    -~----------~----~----~----~------~----~------~--~---
                                                  • Matt Tolton
                                                    ... I don t have ps2pdf on my system. However, I poked around a bit and found pstopdf, which DOES look like it is distributed with OS X.
                                                    Message 25 of 26 , Jul 4 11:41 AM
                                                      > I have a ps2pdf in /usr/bin/ so I *think* it's part of the system (I'm not
                                                      > sure.)

                                                      I don't have ps2pdf on my system. However, I poked around a bit and
                                                      found pstopdf, which DOES look like it is distributed with OS X.

                                                      --~--~---------~--~----~------------~-------~--~----~
                                                      You received this message from the "vim_mac" maillist.
                                                      For more information, visit http://www.vim.org/maillist.php
                                                      -~----------~----~----~----~------~----~------~--~---
                                                    • björn
                                                      Hi, I ve pushed a patch which uses Nico s original suggestion without the delete , i.e. just open the file in Preview and let it handle conversion to pdf.
                                                      Message 26 of 26 , Jul 5 8:53 AM
                                                        Hi,

                                                        I've pushed a patch which uses Nico's original suggestion without the
                                                        "delete", i.e. just open the file in Preview and let it handle
                                                        conversion to pdf.

                                                        Although pstopdf is installed by default on both 10.4 and 10.5 it does
                                                        not give the user any feedback that its processing the file. This is
                                                        weird when you're trying to print a large file because it seems like
                                                        nothing is happening. So using that is out.

                                                        Lots of people think using Automator is overkill. I agree. For now
                                                        we'll rely on OS X to delete the temp files for us. I guess this
                                                        could create problems if somebody never reboots their computer and
                                                        prints large documents several times a day, each day of the year.
                                                        When that user complains we may already have implemented a nicer
                                                        printing system so that we may smugly reply "download the latest
                                                        release!". (One can always hope!)

                                                        Björn

                                                        --~--~---------~--~----~------------~-------~--~----~
                                                        You received this message from the "vim_mac" maillist.
                                                        For more information, visit http://www.vim.org/maillist.php
                                                        -~----------~----~----~----~------~----~------~--~---
                                                      Your message has been successfully submitted and would be delivered to recipients shortly.