Showing posts with label cygwin. Show all posts
Showing posts with label cygwin. Show all posts

Saturday, January 8, 2011

Text - Groff and Mom

v 0.3

I've always had a partiality towards producing documents using text markup.  It has been limited in the past towards having a play writing my on personalised "Man" pages for my Linux machine, or writing html using markup (which drives my Nephew nuts because he likes Dreamweaver).  It rubs off onto my Daughter as well, since she prefers markup for her html coding as well.  Perhaps the fact that she is a Script-writer has something to do with it.

I was interested to see that Groff is included in my Cygwin install (unsurprisingly) so I started to wonder if it was a useful tool for writing letters and other documents.  If you have a useful template, then just changing some of the content is far easier than opening a Word Processor and starting afresh - or even finding that letter that you wrote some time ago to change a few things.  Of course, that the hardware needs of such a system are far less than the requirements of a Word Processor come into play.

The first thing I stumbled on was this linxgazette article on Groff and Mom.  So then I went to the Mom Homepage and started reading further.  Despite Mom being included in Groff (and it is, in Cygwin as well) I downloaded the latest version of Mom to have a look.  Within the file there is the documentation and numerous examples, as well as the macro definition file " om.tmac ".  There is an " install " file to read, however in the end, if you put the " om.tmac " file in the home directory, all should be well (though I haven't tried that yet).

The moment of truth.  I opened a Cygwin command line window, which, since I've set the HOME environment variable, opened in my HOME directory.  I'm not going to go into the logic of the Unix command line here - please refer elsewhere - the Rute User Tutorial on the links page is an excellent place to start.  Using one of the sample " mom " files that came with the Mom download:

groff -mom letter.mom > letter.ps

And low and behold, a postscript file appeared.  The documentation had a slightly different syntax to send the file to the printer, so I tried that, even though my default printer is not postscript.

groff -mom -Tps letter.mom | lpr

The raw postscript printed fine on my default printer, so even though I didn't have the "beautiful" result at this stage, I did know that the command line worked and sent files to the printer.

Windows does not have the capabilities to read postscript files in a viewer that other operating systems do, so the next step is to get Ghostscript, the free Postscript interpreter and viewer.  The presentation of postscript files is a little problematical, depending on the font that is used, however the printed article seems to work fine.

There is a script included in Ghostscript that you can use to convert the file to a "pdf" file.

ps2pdf letter.ps > letter.pdf

NOW you can open the letter in a pdf viewer and print it from there.  You'll notice that the clarity of the text in pdf format is MUCH better than the postscript viewer.

All you have to do now is read the documentation, and have a play.  You are up and running with Mom!!

Update 17th Jan

Other Macro Packages

The other two macro packages I could find documentation for were the "ms" and "me" packages showing how to use them.  See the Links page.


Using Emacs to Edit Groff

Emacs has a built in " nroff " mode.  To activate it, either issue issue the command via:

M-x nroff-mode

or making the first line of your Groff source document:

\" -*- mode:nroff -*-

\"  is the comment in Groff, so the mode instruction line will remain invisible.  Using Nroff mode, all macros will be highlighted for easier editing.


Later ....

Thursday, December 30, 2010

Finding Emacs - An Intermission

I've been having fun working through what Emacs is all about over the last few months.  It is interesting to see what makes it so popular, and since I've also been a fan of VI and VIM, the comparison has been interesting.

Whilst I still think that knowing Vi is essential (it is ALWAYS available for a strange system), Emacs has an irresistible attraction - being built upon a lisp interpreter opens up all sorts of possibilities.  I am firmly sold on Orgmode, and my blog posting of using it with gpg for encryption, whilst basic shows the possibilities.  Symmetric encryption with gpg also makes one wonder why bother with other utilities ....

The thing of beauty that is Emacs is that it is available for whichever platform you use, it is extensive and the effort required to learn it will be repaid many times over in a lifetime.  The term "core competency" comes to mind.

Another thing I've come to accept is that Emacs requires effort to learn.  There is no really easy way.  First do the tutorial, perhaps look at a few websites, but READ the MANUAL.  Let the brain think about it and move on from there.  You cannot learn the piano in a week.

On Windows, if you want to use Emacs, then load Cygwin for any supporting binaries.  Cygwin is just essential.

In a way, the whole thing rather mirrors my journey learning Linux.  At first it was strange, and I bought a boxed set of SuSe Linux about 10 years ago, then I used Red Hat for a while and then Slackware (what a wonderful system).  Finally I settled on Debian.  Only today I was looking at a Windows setup and thinking how much easier Debian was to deal with.

About a year ago, I did a couple of posts about Debian Squeeze as it was then.  There were a few problems as could be expected of it at that stage in its development, however now it is days away from becoming the new Debian Stable.  It is a wonderful system.  Like Emacs, the effort expended in learning Debian Linux is repaid many times over.

But then, like so many things in life, we cannot appreciate these things until we have undertaken the journey.


Later.....

Sunday, December 19, 2010

Finding Emacs - Mail, the Bad and the Good

Having heard that Emacs has two built in email clients (rmail, gnus) I've been trying to get them to work for me.  Everywhere I've read, I have seen people frustrated at not being able to get imap working, and complaining that Emacs freezes when it starts dealing with mail.  So, why is this and is there anything we can do about it?

RMail and Gnus were originally intended to deal with mail from the local network, not remote servers on the internet.  If RMail, for example, is collecting mail from a POP server, then Emacs multi-tasking is lost and it "freezes" until that mail collection is complete.  The good news is that Emacs does come with the "Movemail" program needed to communicate with POP servers, so all this can be done from within Emacs.

Setting up email in Emacs comes at a cost.

The conclusions I've come to are that to use mail effectively, Emacs needs an external mail transfer agent to do the work of transferring the mail to and from the Internet, and then the mail client can do the email management.  Once we make that breakthrough in thinking, the process becomes much easier and more flexible.

And we come again to Cygwin where those unix tools are provided.

Before I finish, I guess I should say that setting both clients up for POP access seems to be reasonably straightforward (haven't done it yet), and with additional SSL binaries even IMAP has been achieved by a few people (though trying to get their incantations to work for me has been elusive).  Having said that, I'd point out that POP is as far as you can go with no additional binaries.  It just seems that Emacs is a whole lot happier if an MTA is used to transfer the mail, rather than Emacs freezing while it does that job.  Having Emacs lock up seems to defeat the purpose of ease of use.

later .....................

Saturday, December 18, 2010

Finding Emacs - W3m and Installation Routines

I keep reading how people use the W3m pager to view the web from within Emacs and I just had to give it a go.  Believe me when I say that it isn't as easy as you might think to set up Emacs for web browsing, certainly not in Windows.  W3m doesn't exist for Windows as a separate easily downloadable binary for a start.

But wait ....... there is Cygwin.

I talked a bit about Cygwin in my last post and it turns out that for installing extensions to Emacs in Windows, that Cygwin is turning out to be the most sensible course of action.  There are exceptions of course, but in my experience there always are.

So, for that "text" web experience, start here ..

Start by downloading and installing cygwin.  It comes as a single file called "setup.exe" which will then ask which internet repository you wish to use, then download the available installation menu for you.  If you are really keen, you can install X and have some graphical Unix tools on your desktop, however we just want to download the " w3m " browser which you can easily find by using the search function included.

Next, Put the path to the " C:\cygwin\bin " directory in your .. er .. PATH environment variable.  The beauty of this is that it will allow you to use other utilities without adding more and more to the PATH, and save you some fiddling to boot.

OK, we have the easy bit done.  Now we have to download and install the emacs-w3m extension.  The extension itself is available from here and at the time of writing the most recent release was 1.4.4 from 2005.
Unpack the archive and place the resulting folder in your " .emacs.d " directory.

Installation.  This needs a bit of thought and is not entirely obvious.  On Windows, we cannot use the " make " utility so there is an alternative provided.

First, change into the emacs-w3m directory that you just unpacked, from in Emacs by using the menu FILE>Open Directory command.

Next, issue the installation command for non-Unix systems given in the web page by using the TOOLS>Shell Command menu selection.

emacs -batch -q -no-site-file -l w3mhack.el NONE -f w3mhack-nonunix-install

We are almost there.  All we need is to make changes to our " init.el " file and it is finished.  Without a thoughtful hack mentioned here, this version of w3m won't work in Emacs 23.

;; w3m
(setq load-path (cons "~/.emacs.d/emacs-w3m-1.4.4" load-path))
(setq load-path (cons "~/.emacs.d/emacs-w3m-1.4.4/attic" load-path))
(require 'w3m-e21)
(provide 'w3m-e23)
(require 'w3m-load)
 Now, restart to re-initialise your PATH variable, hold your breath and start Emacs then:

M-x w3m

and ..... ?

 

later ..............


It worked for me ... your mileage may vary ......

Finding Emacs - Cygwin

Whilst I've been investigating what I can do with Emacs, I've mostly been using a Windows XP machine - not for any reason other than it was there after I'd had to drag it out of a back room into my study to use it for a set of electronic manuals I needed to study.  Why does everyone need to write such things that are dependent on Windows?  Cross platform manuals seem such a logical thing to do.

However back to the story.  I'd started on Emacs with Org-mode for my notes and then I found myself with time on my hands and decided to expand on the Emacs and learn what else I could use it for.  I have rapidly found that the Unix heritage shows through, but I've been resisting and trying to find solutions using purely Windows binaries.  I have finally had to admit that such a course is really too complex and by far the simplest course of action is to use cygwin.


Cygwin

Simply put, Cygwin is a large subset of the Unix system compiled for Windows.  That is oversimplifying it, but essentially correct.  You can effectively use Unix tools in the Windows environment, and since there are no native binaries for a number of utilities required for Emacs extensions (or binaries that need careful searching for) it makes sense just to use Cygwin and have one entry into the PATH variable.

Of course the other advantage of Cygwin is that it provides a gentler introduction to the Unix way for people and who knows, they may even see the sense of a change and abandon the dangers of a computing monoculture.


later ....


Disclaimer:  I'm happy to tell you what I've found if you take responsibility for your actions.

Wednesday, December 15, 2010

Finding Emacs - Mobileorg

 v 0.4
Oct 2011

But wait, there's more!

Orgmode has the ability to be read and manipulated on iphone / ipad / android through mobileorg.  Now to be strictly correct, there is a separate website for dealing with the android platform, however you get the idea.

There are several ways to synchronise between devices, but the method I use is through Dropbox.  Works great.

NOW ... if you use Emacs/Orgmode on Windows, you NEED to know this if you are going to use Mobileorg.  It is essential you download and install in your path the md5sum utility.  The webpage is here, and if you are uncertain which file to download, download the setup file.  The reason is that this file includes BOTH the executables AND the required dll files.  Don't forget to modify the PATH variable so that the system can find the md5sum executable.

And since there's nothing I can add that isn't a duplicate of the Mobileorg site ......



more later .......

Update 31 Dec 2010

With regard to the MD5sum program.  Rather than go through the complexity of the instructions above, download and install Cygwin, putting the cygwin\bin directory in your path.  Using the md5sum from cygwin allows you to simplify the PATH, since there are numberous cygwin binaries (w3m, gpg, gnutls etc)  that are useful for Emacs.

Additionally, the setup given in the Mobileorg page is as clear as mud.  I searched around a bit trying to remember how I set mine up and:

You can play around with the "setup" menu selection under Mobileorg in the Emacs menus, or .. use this example for additions to your init.el  .. obviously you need to modify to suit yourself:


;; Mobileorg
;; Set to the location of your Org files on your local system
(setq org-directory "~/org")
;; Set to the name of the file where new notes will be stored
(setq org-mobile-inbox-for-pull "~/org/newnotes.org")
;; Set to /MobileOrg.
(setq org-mobile-directory "~/Dropbox/MobileOrg")


(setq org-mobile-files (quote ("~/org/A380Notes.org")))



if you want all your org files to be pushed then:


(setq org-mobile-files (quote ("~/org")))


Then to manipulate in Emacs:
M-x org-mobile-push
and
M-x org-mobile-pull


I'm sure there are errors above - will work on it and refine the above later - I know how frustrating it can be trying to find these things out and thought I'd post what I have at the moment.

Update 9 Oct 2011

I spent the afternoon reviewing my MobileOrg setup on a Windows 7 machine. 

To use Emacs / Mobileorg on a Windows machine, you really do need some Unix tools.  Either use Cygwin, or install the GnuWin32 tools from Sourceforge.  (I won't supply the links - google will provide).  You will need "coreutils" (and the "make" utility if you are going to compile any lisp files).  Make sure the GnuWin32 "bin" directory is in your path. (coreutils contains the "md5sum" utility).

Whilst the instructions on the MobileOrg website are correct, I found there were a few "gotchas" that need explaining. 
  • Dropbox has changed its location on a Windows Machine.  It is now just "Dropbox" rather than "My Dropbox".  Took me a while to work out why things were not working when Mobileorg on Emacs said they were.
  • The filename for collecting notes from the mobile device can be anything you like.
  • The "index.org" file format is described correctly, however be particularly careful of the syntax for the link. ... " [[file:first.org][An Org file I like]] " .. as opposed to the http format.
I tried using "Box.net" as a WEBDAV connection, however the link format they use is incompatible with Mobileorg.

The only other thing I can think of  to note is that the file for notes from the mobile device will probably get confused if you have multiple devices collecting notes, such as an ipad AND an iphone.


Later......