2 Replies - 515 Views - Last Post: 10 February 2013 - 06:38 AM

#1 jzbrooks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-February 13

OSX Emacs Problem

Posted 09 February 2013 - 07:24 PM

Hi all. I am trying to find a better emacs solution for Mac OS than the one packaged with the system (specifically one with a GUI). I have both Aquamacs and Emacsformacosx and like both. I have created an alias so I can run them from terminal and allow a file argument to be passed to it. The problem is that if the file doesn't exist already, an error results. I want it to create a file if one doesn't exist already (just like the emacs that is packaged with the system). Any suggestions?
Is This A Good Question/Topic? 0
  • +

Replies To: OSX Emacs Problem

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7651
  • View blog
  • Posts: 12,908
  • Joined: 19-March 11

Re: OSX Emacs Problem

Posted 09 February 2013 - 07:46 PM

Something like this should work:

#!/bin/bash

touch $1
if test -f $1; then 
   /path/to/emacs $1
else
   echo "$1 is not regular file: please try again" >&2
fi 




Give that a convenient alias - for example, "emacs" :)/> - and you should be good. touch will ensure that the file exists, if you have write permission on the directory involved. The test is just in case you happen to pass a folder name as an argument.

Fair warning, I haven't actually tested this, so you might have to monkey with it, but I think it should do what you're looking for.


EDIT: it would be reasonable to use a test -e after the touch to see whether the file has been created. If not, that's probably a permissions issue, and you could inform the user of that.

This post has been edited by jon.kiparsky: 09 February 2013 - 07:48 PM

Was This Post Helpful? 1
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,496
  • Joined: 23-August 08

Re: OSX Emacs Problem

Posted 10 February 2013 - 06:38 AM

Helpful vis-a-vis Aquamacs.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1