Posts filed under ‘Emacs’

MobileOrg is cool

Recently I began to use mobileOrg to synchronize my org file with
iphone. It works great. Now I can look at my schedule and use Capture in
iphone. The Work flow like this:

For emacs to iphone,

  • Run in emacs:
M-x org-mobile-push

or C-c C-x RET p

This will push org file to a Dropbox folder which share with iphone

  • Click sync button in iphone and thus update the org-file in iphone

For iphone to emacs,

  • Add note in Iphone
  • Run in emacs:
M-x org-mobile-pull

or C-c C-x RET g

Now notes are located in flagged.org, you can open it and use C-c C-w
to refile to other places.

February 8, 2012 at 4:55 am 4 comments

How to use org-mode to write blog

I begin to write blog recently, naturally I choose org-mode to do this
task. However, org-mode export to html with whole page of html tags with
head and body. While writing to blog, we only need the body part. When I
just copy the body part, I loose its format. If I copy the whole html,
blogspot general some unwanted space, title, etc and I also lost title
link. I read w3schools.com about html and css and realized that if I can
change the template of blogstpot.com, add those css, I should be able to
keep the format. Read google’s own online help, and then I changed my
template, done! Only thing left is that I still need manually copy body
part. After a long search, I known that there is a variable
org-export-as-html whose fifth option can be set to body-only
(refer to discuss part in EMACS-FU ). But I known very little about
lisp. A promising setting is from http://comments.gmane.org/gmane.emacs.orgmode/18069

,----
|   (setq html (org-export-region-as-html beg end t 'string))
`----

I tried substituting the string with body-only, but it’s wrong.
Thanks to Tamas K Papp’s blog, who gives the whole solution. The only
thing I didn’t follow his solution is CSS apart for syntax highlight,
since inline-css works for me. If I choose ccs instead of inline-css,
local html will be generated without syntax hight.

So the whole step is

  1. Copy CSS part of a org-mode generated html into template of blogspot
    (Only part 1 of CSS mentioned in Tamas K Papp’s blog). The first
    line should be removed, since it cause some problem, especially when
    I use them in wordpress.com, it cause <pre> part not overflow
    (scroll bar not shown when space is not enough), i.e.

    html { font-family: Times, serif; font-size: 12pt; }
    

    The location
    is to add CSS is

    <b:skin>
      ....
     * Varaible definitions apart
    
      CSS you added
    
      original CSS setting
      ....
     </b:skin>
    
  2. add following line into .emacs file

    (defun org-export-body-as-html ()
    (interactive)
    (org-export-as-html 3 nil nil "blog" t))
    
    (add-hook 'org-mode-hook
           (lambda ()
             (local-set-key (quote [?\C-c ?\C-x]) 'org-export-body-as-html)))
    
  3. Use C-c C-x to generate body part of the blog
  4. Use scribefire to update blog and preview the results. I feel this is
    more convenient than webloger.el. Since webloger.el cannot update
    title and set label, I have to manually change it every time if I use
    this. Need use new version scribefire, old version have bugs, when
    encounter `<‘ and `>’ inside <pre> tags, it convert them into `&lt’,
    and ‘&gt’ respectively. While <pre> tags may have other tags inside
    them, especial for color setting <span>.

  5. If use blogspot to update blog, in post option part, choose Use br tags. Otherwise, unwanted line breaks will be added.

October 10, 2010 at 4:51 am Leave a comment

Make your emacs init file know your machine

My laptop screen is glossy, and so only light theme or default theme is
suitable, while all other machine is okay to run great dark theme. So
today I add following code into my .emacs file to do this
automatically.

(when  (not (equal "archkicad\n" (shell-command-to-string "uname -n")))
  (load-file "~/.emacs.d/color-theme-blackboard.el")
  (require 'color-theme)
         (eval-after-load "color-theme"
           '(progn
              (color-theme-initialize)
              (color-theme-blackboard)))
)

Here archkicad is the name of my laptop, which will not use any theme.

./default32.png

October 10, 2010 at 4:51 am 2 comments

Use your mouse to resize emacs widows

It’s easy to split emacs windows with binding keys, C-x 2 and C-x 3,
for horizontally and vertically, respectively. But resizing it with C-u xx C-x C-}, or C-x C-^, or C-x C-v is somewhat
cumbersome. Fortunately, mouse can do this for us.

  1. Resize horizontally: move mouse cursor to those dash line in
    mode-line, and then just drag it.

  2. Resize vertically: move mouse cursor to the area just under the
    split line, in the mode-line. When it shows double horizontal arrow,
    drag it.

  3. Split vertically: move to mode-line, and C-mouse-midle-key.

  4. close window: right click mouse on the mode-line.

Is it nicer? Enjoy it.

October 10, 2010 at 4:51 am Leave a comment

Org-babel is great!

I just installed org-mode 7.01h and tried babel. It’s great. Now you can
put different programs and their results with document together. Here are some examples.

ruby

require 'date'
"This file was last evaluated on #{Date.today}"
This file was last evaluated on 2010-10-10

octave

example 1

n=[1:10];
x=2*n;
ans=x
 2.00000000e+00 4.00000000e+00 6.00000000e+00 8.00000000e+00 1.00000000e+01 1.20000000e+01 1.40000000e+01 1.60000000e+01 1.80000000e+01 2.00000000e+01

example 2

A=[1 2];
B=[2 3]';
C=A*B;
ans=C
 8.00000000e+00

p

 8.00000000e+00

October 8, 2010 at 9:58 pm Leave a comment


Recent Posts

Archives

Blog Stats

  • 1,013 hits

Follow

Get every new post delivered to your Inbox.