Showing posts with label Text. Show all posts
Showing posts with label Text. Show all posts

Friday, October 14, 2011

Finding Emacs - Colours,Toolbar and Variables

v 0.2
14 oct 11


Colours

I was wondering about setting colours in Emacs ... and then started wondering about Themes and even how to find out what variables to set.

Well, here is a website that gives all the colours you can set:


http://raebear.net/comp/emacscolors.html

How can you use them?  Well to start off, try putting this in your init file ....

(set-background-color  "grey95")

It is a very simple change - changes the background to light grey, however you get the idea.


Themes

Try this website to view a few:
http://color-theme-select.heroku.com/

Toolbar

Want to determine whether the toolbar is on or off?

(tool-bar-mode t)


Variables

I found this list this morning, however there are a lot more than this:
http://www.gnu.org/s/libtool/manual/emacs/Variable-Index.html


Later ....

Thursday, January 13, 2011

Finding Emacs - "Learning GNU Emacs"

v 0.2
I was googling for some information on "nroff-mode" in Emacs, and unexpectedly, I found a Google copy of "Learning GNU Emacs" in Google Books.

I now have found two brilliant books on Emacs.  First is the reference manual by Richard Stallman, and the second is this.  From what I've read of it so far, I think Amazon will sell another copy.  Unlike most, this is more of a TUTORIAL rather than a reference manual, so it lets you put things in perspective.

As I have come to realise, Emacs is a long term project - but one which will repay the effort many times over.



Later.

Update

There are significant differences between the 2nd and 3rd editions.  For example, Mail is not covered in the 3rd edition.

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.....

Tuesday, December 21, 2010

Finding Emacs - A Personal Information Manager Part 1

Over previous posts, I've been building Emacs capabilities.  It occurred to me that I had a secure information manager that I could take anywhere with me and that I could recover anywhere.

Here are the components.

  • Emacs
  • My Encryption post
  • My Orgmode Outlines post
  • DropBox

Use an Orgmode outline to structure your data - save it using encryption previously described and then copy it to Dropbox.  Secure, and you can re-create the information on ANY platform with nothing but the knowledge it can be done, this Blog, and Dropbox.

Sounds good to me.




later .......

Sunday, December 19, 2010

Finding Emacs - Orgmode, Outlines and Ascii Export

I mentioned earlier that I came to Emacs because I thought Orgmode would be a great thing to use.  Cross platform, readable format and a powerful tool once it has been learnt.  To make the learning curve a little flatter, here is how to do a simple outline in Orgmode, and to export it to a text file.

I've already pointed to the link that shows the few lines that are needed to be inserted in the " init.el " file, so all we need to do is to open a file and start.  I name all my orgmode files with the suffix " .org " - makes it easier to recognise, and Emacs will know that we want orgmode.  The first lines of an orgmode file I open are:

-*- mode:org ; mode:visual-line -*-
#+STARTUP: indent
#+OPTIONS: H:4


The lines re-confirm it is an orgmode file, and ensure the system is set up for wordwrap the way I like it.  I tell orgmode I want the headings arranged in a more readable format, and that when I export, I want down to four levels of headings (the default is three).

To start a level one heading, type something like:

* heading one

  • If you now type M-RETURN, you will get another level one heading below it ready to name.
  • Once you have your second level one heading, type M-RIGHTARROW - you now have a level two heading. Try M-LEFTARROW now.
  • Note the coloured headings - a different colour for each heading level
  • With two level one headings, experiment with M-DOWNARROW and M-UPARROW and see that the headings (and all their sub-trees) swap around
  • If you type RETURN, then you can simply start typing text.

Want to do a list?  Try this:

list header
- list item

at the end of the " - list item " line, M-RETURN and there is the next item started for you.

Exporting

Want to export as a plain, formatted text file?
Org>Export/Publish..  menu item

A new buffer appears in a split (is that a window or a frame, he thinks)  and type   "  a  " from the list of possibilities, and the export is confirmed in the mini-buffer at the bottom.  It appears as a " .txt " file in the same directory as the " .org " file you were using.

Here is what I got:


         -*- mode:org ; mode:visual-line -*-
         ========================

Author:  
Date: 2010-12-19 11:26:27



Table of Contents
=================
1 heading one
2 Another heading


1 heading one
^^^^^^^^^^^^^^

2 Another heading
^^^^^^^^^^^^^^^^^^^
list header:
- list item
-


Of course, if you want to avoid the the first line starting with -*- , there are several ways you can easily do this, but I won't go into that now.  One final note, when you export to HTML, it follows the HTML logic, so that if you have an informal list like so:

item one
item two
item three

Then they will appear in the HTML export as:

item oneitem twoitem three



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

Update 12 jan11:

You can comment out the first line "-*- mode:org ; mode:visual-line -*-" to be:

# -*- mode:org ; mode:visual-line -*-

and it will not appear in the export and it will still give you the presets for your file.

Wednesday, December 15, 2010

Finding Emacs - Add an External Mode, Predictive, Byte Compiling

I've tried to keep these posts short to illustrate one point that will be easy to find (for me as well when I need to remember) however I'm combining three things here because they dovetail so well and really depend upon each other.


Add an External Mode

Modes in Emacs are really collections of Emacs Lisp files collected together in a directory.  You tell Emacs about them by referring to them in the " init.el " file.

This is where I believe that using the standard Emacs intitialisation structure even for Aquamacs is an excellent idea.  Use the " .emacs.d " initialisation directory and place the external modes you are adding into this directory. That way it is all neatly packed together.


Predictive


I first read about predictive on this page.  It gives a good introduction to what it is all about and how to do Byte compiling of Lisp files on a Windows machine.  Normally, when you add an external mode, they give a " makefile " which is not much good to you in Windows, however you can simply do a manual version of it using Byte Compiling using Dired.  I will repeat a couple of points on my linked page, just in case it becomes broken at some stage in the future, which will not be much good to me if I've forgotten it and am trying to piece things together again.

So, obtain Predictive from here.  I used a Windows archive utility (check freewarefiles) to unpack the " tar.gz " file into a folder called " predictive ".  Place this folder in the " .emacs.d " directory.

These are the lines I put in my " init.el " file to point to the directory.

;; Predictive
(setq load-path (cons "~/.emacs.d/predictive" load-path))
(autoload 'predictive-mode "predictive" "predictive" t)

You are all set now (after you restart Emacs to get the init.el file re-read), you can manually start predictive-mode by:

M-x predictive-mode (RETURN)

See my post about File Variables for an automagic way of starting it.

It now all works ....... errrr ........ sooorrrrttttt of.

It is sooo slooowwww it is almost unuseable.  To speed things up, we need to ...


Byte Compile Lisp Files

This is where that previous post on Dired comes in handy.  We can change to the appropriate directory, mark the files and then byte compile them from within Emacs.

C-x d ~/.emacs.d/predictive RET
% m \.el$ RET  
B                        
  • With the first line, we open Dired, changing to the predictive directory
  • The next line (starting with the % character) marks all the  " .el " files
  • Finally, the command " B " tells Emacs to start byte compiling all the marked files.  You will only have to reply " yes, or y " to confirm you want it to start.
The byte compilation will take some time, so don't worry, it will get there.  Once it is finished, restart Emacs and now you are on your way with a much faster and useable " predictive mode "


later .....

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......

Finding Emacs - Orgmode

A suitable sub-title for this post would be:

Just how deep does this rabbit hole go?

I couldn't possibly show how to use orgmode in a blog posting.  It is far more profitable to visit the orgmode website and view the youtube videos and tutorials.

Instructions as to the text to insert into your " init.el " file are in the activation section of the orgmode manual.

What I can do though is to give you an overview and just a hint of what you are able to achieve using orgmode.  Orgmode has been likened to being an "Office suite" for Emacs and the comparison is not too far from the truth.  In its basic iteration, orgmode seems to be an outliner, which is where it started life however it also has to-do list capabilities, agenda views, the ability to produce a nicely formatted table and to run spreadsheets and formulas within a text orgmode document.  Then there are the export capabilities - we start with exporting your document as an ascii text document whereupon you see a nicely formatted document with a table of contents at the front.  Then you can export to HTML if you wish or make a beautifully indexed PDF or Latex document.

I suppose I should tell you that Orgmode is included in Emacs.

Finally, these are first lines I put into an orgmode file:


-*- mode:org ; mode:visual-line; mode:predictive -*-
#+STARTUP: indent
#+OPTIONS: H:4

The first line I have discussed previously, however the next two lines are specific orgmode instructions that you can read more about in the manual.  The first tells orgmode to indent sub-headings so as to make the document more readable, and the second tells orgmode to export as separate headings down to 4 levels of headings.  If you have, say 5 levels, they will be exported, but not placed as a heading, just text.

I leave the rest to your curiosity.


more later ...........

Finding Emacs - Customising Automatically per File

psst ..... listen verryy carefully ... I shall say this only once ...

The secret search term is  "emacs file variables"

To set modes and variables for an individual file, place a line such as that below on the FIRST line of the file.

-*- mode:org ; mode:visual-line; mode:predictive -*-

What this line means is to set the file for orgmode, word-wrap and predictive text typing.  Saves having to enter keystrokes to set the environment how you want.

There is an alternative syntax that can be used at the end of the file, however I'll leave you to read the reference for that.

Update 17Jan11

Placing the particular comment character for the source file you are using in front of the customisation line will render it invisible in the output, so for orgmode, it would look like this:

# -*- mode:org ; mode:visual-line; mode:predictive -*-

more later ...



I'll leave you to spot the errors ..... :)

Finding Emacs - to Word Wrap or to Truncate

When I started using Emacs, which was only a few months ago when I discovered org-mode, I spent a little bit of time working out how to organise the word-wrap of text files.

The menu selection "Options>Line Wrapping in this Buffer" has the answer.
  • Truncate lines simply means that the line will continue until you terminate the line and you will only see a small amount of it in the window.
  • Visual Line Mode is what we typically think of word wrapping in the window.
  • Wrap at Window Edge is another line wrap mode which appears to work, however I prefer the previous two modes as I'm using the editor.
Remember, you will probably have to set the wrap manually.

.... unless .... you have learnt to set the modes and variables per file.

Tuesday, December 14, 2010

Finding Emacs - Encryption

v 0.3
It is quite easy to use encryption with Emacs.  Ensure you have gpg installed - under Windows, you can either install gpg for windows, or install it through Cygwin.  Under OSX and Linux, gpg will most probably already be installed.

So, if you have Windows, download and install gpg for windows or install Cygwin with gpg

In any event, add these lines to your " init.el " file


;; Encryption - symmetric gpg
(require 'epa)
(epa-file-enable)


  • Any file with the ending " .gpg " will be taken as encrypted.
  • When you open or save such a file, you will be asked for a password.
  • If you use orgmode, then a file of the format " filename.org.gpg " will be taken as ormode and encrypted.

This will result in a symmetric encryption scheme - you will need to provide the password to open the file, and the password twice to encrypt it.  That is it.

Update 28Jan11

After having not used "Aquamacs" and my Mac laptop for some time - because I was at home rather than at work - I discovered that using Aquamacs with "gpg" encrypted files as above brought up the MacGPG interface (which is rather nice).  SO, if trying to use encryption on the Mac doesn't "just work", then you might want to go to MacGPG at sourceforge and download their binary (1.4.9 is the version I've been using).  Apologies for any frustration.

Have you been certified to be let out unsupervised?

Finding Emacs - Spell Check in Windows

Default spell check in Emacs is Ispell.  Well, I had a look and took someone's advice and went with Aspell.  Here are the steps.




The init.el modifications are:


;; Aspell
(setq-default ispell-program-name "c:\\Program Files\\Aspell\\bin\\aspell.exe")


Now all the spell check menu items in Emacs work like a charm.

Do I REALLY need to tell you that you are responsible for your actions?


more later .......

Finding Emacs - The Window is a Frame and the Frame is a Window

Emacs was written before Microsoft Windows came on the scene, so the terminology is different.  Consider when you first fire up Emacs.  There is one window looking at you with a menu bar and toolbar at the top.

Weeelllll .. almost.

The outer border is a FRAME.  Inside that is one WINDOW.  You can have several divisions inside a frame, each of which is called a window.  You can play with this with the File menu.  Select new Frame.  Split the window, and remove the splits.

Now for Buffy ... er ... Buffers.


  • The term "buffer" is effectively a file in memory.  
  • You can choose from the list of buffers to show one in a window using the buffer menu  and you can look at the same buffer in any number of windows.  
  • You can open or close a buffer from the File menu.  
  • One final twist.  If you are playing a game, or using one of the associated programs from within Emacs, that program is a buffer.  
  • You can close it using the File-Close menu selection, or select another to use from the Buffer menu.



Easy ... er ... yes ....


Later.

Finding Emacs - the Growing Links List

Finding Emacs - Installation

 v 0.3
12 Oct 11

(Note - see updated post dated Oct 11)

There are probably three questions that come to mind when installing Emacs:
  • Where does the program go?
  • Where is "Home" on this platform?
  • How is the Emacs initialisation / configuration file organised?


Where does the program go?

OSX and Linux have this pretty well sorted out and it is only on Windows that you have to make a decision.  Of course "Program files" is the obvious first choice, however since Emacs is normally distributed for Windows as the straight binary with no installer, I tend to put it (and other such programs) in a " C:\pro " directory, so that the path becomes "C:\pro\emacs " .



Where is  "Home" ?

Home is pretty obvious when you think about it - except for Windows.  So where is it in Windows?  Depends.

For Windows XP it is "C:\Documents and Settings\username
For Windows Vista and 7 it is "C:\Users\username

where username  represents whatever your username for your account is.

..... but wait!

For Windows XP at least, when you have a look at the environment variables, THERE IS NO HOME!  The variable is called HOMEPATH - not much use to Emacs.  So, make an environmental variable "HOME" to make things to your liking, and this is what I have done.

Should you want to set your "HOME", in Control Panel, go to System>Advanced>Environment Variables>User variables.


How is the Emacs initialisation / configuration file organised?

Conventional positioning now is that the Emacs init file is in " ~\.emacs.d\init.el ".  Aquamacs has a different position in preferences - " ~/Library/Preferences/Aquamacs Emacs/Preferences.el " where, whilst it will understand the traditional init file, it will use Preferences.el if it can.

A significant advantage of using the " .emacs.d " directory is that you can put other emacs related files and directories in it and use it all from one place.

Some notes on Unix nomenclature.
  • The " ~ " character at the front of a pathname refers to the " home " directory.
  • A dot at the beginning of a file or directory name will hide that item in Unix.
  • Directories in Unix often have a " .d " at the end to distinguish them from files.  So " .emacs.d " is a hidden directory, whilst " .emacs " is a hidden file and " emacs " is a visible file.

Update 25 Dec 10

Clarifying for Windows XP - I make my "HOME" as "C:\home" - this makes it easy for me to sort things as my machine is a single user machine - if there are several accounts, then the homepath given above may well be the better way to go.

..... later

disclaimer - this worked for me, it may not work for you.




Monday, December 13, 2010

Finding Emacs - Why?

 v 0.3
Updated 12 Oct 11


A sometime series I thought I'd post as I work out how to use this amazing piece of software.

At first blush, you look at Emacs and think:

  • "Hey, it is only an editor - what can the fuss be?  There are heaps of editors out there that do great stuff, and are easier to use to boot!"
  • Then you hear more, about the wars with Vim and then the extensibility or something.
  • And then you find out about Orgmode and discover that many people only come to Emacs because of this.  And then they are lost forever.


Why is Emacs Different?

Emacs is different because at its heart, it is a Lisp interpreter around which all the routines are built.  It is putty and it is extensible to do whatever you want.  Start using it as an editor, then discover the calculator, the calendar and then the games.  Use orgmode for outlines, agendas and then export to latex.  Discover the newsreader, email client and then the web-browser.

Perhaps a tour is in order.


Which Computers will it Run on?


What system do you use?  You can download and run Emacs on pretty much any platform you can think of.  If you run Unix or Linux then you probably already have Emacs included - at least in the Terminal, if not on the desktop.

Emacs for Windows
Emacs for OSX
Aquamacs for OSX


Investment in the Future

Learn Emacs and you have it for life.  Doesn't sound like much, but the more you invest in learning to use Emacs, the richer your long-term rewards.  It can do so much that replaces those one-off programs you buy and use for a while.  Emacs can stay with you no matter which computer you buy in the future.  It will always be there to get you out of that hole.

Update 12 Oct 11

It's been a year since I wrote this, and can only say that it understates the case for Emacs.  As I've learnt how to manipulate this piece of software, I can only say that the effort has been well worth it.

Learn Emacs and its tools, such as Orgmode and you will have a highly capable authoring and organising tool that you can use on any computer for as long as you wish.


disclaimer - this worked for me, it may not work for you.


more later ......