Using Emacs and org mode for quick generating of presentation slices

Posted in Emacs on October 23, 2009 by zhangda

Following emacs-fu’s post on how to generate pdf slices using Emacs and org-mode,  I found some tricks to write down:

(1)  when include an image in the sub folder, the formula is:

#+LaTeX:\includegraphics[height=0.45\paperheight]{img//Scan_Type_dialog.jpg}

or use the latex code directly:

\begin{figure}[H]
\centerline{\includegraphics[height=0.45\paperheight]{img/Scan_Type_dialog.jpg}}
\caption[]{Scan Type Selection Dialog \label{fig:scan_type_dialog} }
\end{figure}

(2) structure

* big section

** slice title

*** sub item

**** sub sub item

italic font in org-mode

Posted in Emacs on October 18, 2009 by zhangda

I am trying to follow Emacs-fu’s wonderful post on how he use org-mode in various tasks, including note taking and presentation preparation. He mentioned in his post that /word/ in org mode can change the display font into italic (/word/, which seems quite cool. But this did not work for me at the beginning. I did a little research on this issue and found the following problem:
(1) in my own switch-color-theme-matlab-latex.el, which setups several themes I daily use and switch among, the italic was not defined properly: I put too many entries in that face, but ignore the most fundamental one: :slant italic.
(2) the font I am using (Andale Mono) for windows does not work very well with Emacs’s italic display. I changed my default to Bitstream Vera Sans Mono, which is both available in Windows and Linux.

After this changes, the /italic/ works well, and the font actually saves me more display area.

Excel break external links

Posted in Uncategorized on October 7, 2009 by zhangda

From the MS Excel help I found this useful information:

Important When you break a link to a source, all formulas that that use the source are converted to their current value. For example, the link =SUM([Budget.xls]Annual!C10:C25) would be converted to =45. Because this action cannot be undone, you may want to save a version of the file before you start.

On the Edit menu, click Links.

In the Source list, click the link you want to break.

To select multiple linked objects, hold down CTRL and click each linked object.

To select all links, press CTRL+A.

Click Break Link.

If the link used a defined name, the name is not automatically removed. You may want to delete the name as well.

How?

On the Insert menu, point to Name, and then click Define.

In the Names in workbook list, click the name you want to change.

Do one of the following:

Change the name
Type the new name for the reference, and then click Add.

Click the original name, and then click Delete.

Change the cell, formula, or constant represented by a name
Change it in the Refers to box.

Delete the name
Click Delete.

renaming multiple files in a few seconds using Emacs wdired

Posted in Emacs on September 11, 2009 by zhangda

I used to write a short script in case I need to rename a lot of files, following some logic.
For example, I have scanned many pages of a manual and got these files:
1.jpg
2.jpg

10.jpg
11.jpg

100.jpg
101.jpg

For acrobat to combine them into one pdf file, it’s better to have them in the correct order, but acrobat by default sort them as:
1.jpg
10.jpg
11.jpg

100.jpg
101.jpg

2.jpg

Then it’s easier for me to rename them into:
001.jpg
002.jpg

As I said, I used to write a short script to do this. But today Emacs taught me an faster alternative: wdired

According to the GNU Emacs Manual:
"Wdired is a special mode that allows you to perform file operations by editing the Dired buffer directly (the W in Wdired stands for writable.) To enter Wdired mode, type C-x C-q (dired-toggle-read-only) while in a Dired buffer. "

You can also enter wdired by M-x wdired-change-to-wdired-mode.

This mode allows you to change the properties file such as file names, permissions, by editing the dired buffer.

So for the above problem, I just simply use rectangle editing, and add the preceding 0 or 00 to the file names.

Emacs is truly great and a productivity booster!

use Emacs dired as a general browser in windows

Posted in Emacs on August 22, 2009 by zhangda

When browsing with Emacs dired on directories which usually contains some different files Emacs may or may not access smoothly(such as a pdf file), it is desirable to launch the Windows application from inside dired. For example, although Emacs can display pdf file with the help of doc-view-mode, it lacks the common convenience from Acrobat Reader.

After searching on for a little while, I found this wonderful package: w32-browser.el (http://www.emacswiki.org/cgi-bin/wiki/w32-browser.el). To implement this with dired, I used the following key-bindings in my .emacs:

;;; Hack dired to launch files with ‘z’ key and mouse clicking
(require ‘w32-browser)
(setq dired-load-hook
(lambda (&rest ignore)
(define-key dired-mode-map
“z” ‘dired-w32-browser)
(define-key dired-mode-map
[mouse-2] ‘dired-w32-browser)))

two face names

Posted in Emacs on August 22, 2009 by zhangda

Today I tried to customize the faces of the marked region and the highlighted region which the mouse is over. It took me quite a few minutes to find the correct name of the faces:

region

highlight

Just to take a quick note on them.

outline-minor-mode-prefix manually changed to C-o again

Posted in Emacs on August 9, 2009 by zhangda

After the exciting upgrade of my current CVS Emacs to the newly released Emacs 23.1, I have to manually edit the outline.el file again to change the outline-minor-mode-prefix to “C-o”. According to my personal preference on the outline mode, the default “C-c @” commands seems too long and awkward to type. Therefore I am used to the following hacks in my .emacs file:

;; bind the outline-minor-mode-prefix C-c @ to C-o
(global-unset-key (kbd “C-o”))
(global-set-key (kbd “M-o”) ‘open-line)
;; Set the minor mode prefix to C-o
(setq outline-minor-mode-prefix “\C-o”)

However, from emacs 23, this hack does not work anymore. I have to manually edit the installation_dir/lisp/outline.el to change the outline-minor-mode-prefix from “C-c@” to “C-o”. Then I have to byte-compile the outline.el to outline.elc again. I wonder if there is another more elegant way to do this job, other my current ugly approach??

By the way, I think the outline mode is better for documents instead of codes, therefore I only added the following hooks:

;; add hook to the following major modes so that the outline minor mode starts automatically
(add-hook ‘muse-mode-hook ‘outline-minor-mode)
(add-hook ‘html-mode-hook ‘outline-minor-mode)
(add-hook ‘LaTeX-mode-hook ‘outline-minor-mode)

Acronis may generate inaccessible folders and files, and the SOLUTION

Posted in Uncategorized on July 3, 2009 by zhangda

About a month ago I did a complete backup of my work PC using Acronis, and today I want to restore some important files and folders to my laptop. I tried to use the restore specific files and folders option of the Acronis, but when it started working, it kept quitting and left me some inaccessible folders and files. For example, I tried to restore the Emacs.lnk file to my SendTo folder (under C:\Documents and Settings\username), but it left me a tree of dir which is not accessible, nor removable.

The old school for windows users, if we still remember, should be: "reboot from a CD, access DOS, delete the folders". But the problem with the folders and files generated by the Acronis software is, it denies any access to them. So I did the following trick:

(1) killed the explorer process, in case the folders or files are being used by the Windows system.

(2) opened cygwin command line console

(3) tried to access the files or folders

(4) when permission got denied, I used chmod 777 "filename/folder name" to regain the access

(5) rm or rmdir the files or folders from inside out

(6) start the explorer again from the task manager

NTLDR and NTDETECT.COM under windows root partition

Posted in Emacs with tags on July 2, 2009 by zhangda

I mistakenly deleted the NTLDR and NTDETECT.COM files from the Windows XP root partition, then BOOOM!~~I cannot boot into Windows XP any more…

To solve this, I copied from the i386 folder of a WinXP installation disk to the root partition (in Linux), then everything went back again.

Customize Emacs Automatic Scrolling, and stop the cursor from jumping around as I move it

Posted in Emacs on May 21, 2009 by zhangda

I used to set up the Emacs auto scrolling using the following lines, as someone online claimed this would result in “smooth scrolling”:
(setq scroll-margin 3
scroll-conservatively 10000)

However, when the cursor moves near the top or the bottom of the frame (or the window), Emacs automatically recenters and place the cursor in the middle of the screen. This has been bugging on me for too long. My personal preference of the cursor is: when I move it up or down near the screen top or bottom, I would like to have Emacs JUST MOVE 1 LINE for me, so I can follow naturally the movement of the cursor. If I need to recenter the screen and place the cursor in the middle, I would do it myself by calling C-l. I don’t need Emacs to move the cursor for me!

Today, after some searching, I finally figured out that the annoying jumping around of the Emacs cursor is due to the Automatic Scrolling of Emacs.

The idea of Automatic Scrolling, according to http://ecs.victoria.ac.nz/cgi-bin/info2www?(emacs)Auto+Scrolling, is:

“Redisplay scrolls the buffer automatically when point moves out of the visible portion of the text. The purpose of automatic scrolling is to make point visible, but YOU CAN CUSTOMIZE MANY ASPECTS OF HOW THIS IS DONE.”

There are four variables to be customize for the Automatic Scrolling feature of Emacs:

  • scroll-margin: restricts how close point can come to the top or bottom of a window
  • scroll-conservatively: if you set it to number N, then if you move point just a little off the screen–less than N lines–then Emacs scrolls the text just far enough to bring point back on screen
  • scroll-up-aggressively: a number (F, meaning fraction) between 0 and 1, and it specifies where on the screen to put point when scrolling upward. More precisely, when a window scrolls up because point is above the window start, the new start position is chosen to put point F part of the window height from the top
  • scroll-down-aggressively: a number (F, meaning fraction) between 0 and 1, and it specifies where on the screen to put point when scrolling downward. More precisely, when a window scrolls down because point is below the window bottom, the new start position is chosen to put point F part of the window height from the bottom

Based on these explanations, I configured my Automatic Scrolling according to my personal preference:

;; for smooth scrolling and disabling the automatical recentering of emacs when moving the cursor
(setq scroll-margin 1
scroll-conservatively 0
scroll-up-aggressively 0.01
scroll-down-aggressively 0.01)