How to set Firefox as the default browser under Windows 10 when it does not show up in the default program list under “Default apps”

 

1 Summary: after re-install Firefox (version 65.01 64-bit), I cannot set it as the default browser of Windows 10. It turned out that the registry entry of Firefox was messed up.

1.1 symptoms

  • under Windows 10, Firefox did not appear in the program list under “Default apps”Set_FF_default_browser
  • after the fix, Firefox reappeared in the program list

1.2 the two major Firefox registry entries are: FirefoxHTML, FirefoxURL

1.3 detailed settings

  • FirefoxHTML
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML]
    @="Firefox Document"
    "FriendlyTypeName"="Firefox Document"
    "EditFlags"=dword:00000002
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\DefaultIcon]
    @="C:\\Program Files\\Mozilla Firefox\\firefox.exe,1"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell]
    @="open"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open]
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open\command]
    @="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -osint -url \"%1\""
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open\ddeexec]
    @=""
    
    
  • FirefoxURL
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL]
    @="Firefox URL"
    "FriendlyTypeName"="Firefox URL"
    "URL Protocol"=""
    "EditFlags"=dword:00000002
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\DefaultIcon]
    @="C:\\Program Files\\Mozilla Firefox\\firefox.exe,1"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell]
    @="open"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open]
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open\command]
    @="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -osint -url \"%1\""
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open\ddeexec]
    @=""
    

1.4 how I figured out this is the issue

  • I compared the settings of Chrome, which also has ChromeHTML and ChromeURL
  • I also found the FirefoxHTML and FirefoxURL entries, but the original settings were strange (the “kernel32::GetLongPathNameW” lines below):
    • FirefoxHTML
      Windows Registry Editor Version 5.00
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML]
      @="Firefox HTML Document"
      "FriendlyTypeName"="Firefox HTML Document"
      "EditFlags"=dword:00000002
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\Application]
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\DefaultIcon]
      @="C:\\Program Files\\Mozilla Firefox\\firefox.exe,0"
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell]
      @="open"
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open]
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open\command]
      @="\"kernel32::GetLongPathNameW(w R8, w .R7, i 1024)i .R6\" -osint -url \"%1\""
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open\ddeexec]
      @=""
      
    • FirefoxURL
      Windows Registry Editor Version 5.00
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL]
      @="Firefox URL"
      "FriendlyTypeName"="Firefox URL"
      "URL Protocol"=""
      "EditFlags"=dword:00000002
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\DefaultIcon]
      @="kernel32::GetLongPathNameW(w R8, w .R7, i 1024)i .R6,1"
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell]
      @="open"
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open]
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open\command]
      @="\"kernel32::GetLongPathNameW(w R8, w .R7, i 1024)i .R6\" -osint -url \"%1\""
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxURL\shell\open\ddeexec]
      @=""
      
  • I also found in the registry another pair of FirefoxHTML-XXXXX and FirefoxURL-XXXXX (with XXXXX being a random alphanumeric string). So I thought, maybe the messy FirefoxHTML and FirefoxURL were from the old installation, and the -XXXXX version were the correct version.
    • I then just backed up the messy registry entries, removed them, and renamed the -XXXXX version into FirefoxHTML and FirefoxURL
    • PROJ-DONE then problem solved
Advertisement

Configurations for beautifying Emacs org mode

Configurations for beautifying Emacs org mode

1 Summary

  1. Purpose of the configuration: to beautify org-mode’s appearance with some eye-candies
  2. The configuration contains the following parts
    • choose the right font and fall-back font
    • enable utf coding
    • select org-bullet symbol set
    • select org-ellipsis symbol
    • define the faces of org-bullet

2 choose the font and fall-back font

;; set the fall-back font
;; this is critical for displaying various unicode symbols, such as those used in my init-org.el settings
;; http://endlessparentheses.com/manually-choose-a-fallback-font-for-unicode.html
(set-fontset-font "fontset-default" nil 
                  (font-spec :size 20 :name "Symbola"))

;; Setting English Font
(set-face-attribute
  'default nil :stipple nil :height 130 :width 'normal :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant 'normal :weight 'normal :foundry "outline" :family "DejaVu Sans Mono for Powerline")

3 enable utf coding

;; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(setq utf-translate-cjk-mode nil)

(set-language-environment 'utf-8)
(setq locale-coding-system 'utf-8)

;; set the default encoding system
(prefer-coding-system 'utf-8)
(setq default-file-name-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; backwards compatibility as default-buffer-file-coding-system
;; is deprecated in 23.2.
(if (boundp buffer-file-coding-system)
    (setq buffer-file-coding-system 'utf-8)
  (setq default-buffer-file-coding-system 'utf-8))

;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))

4 select org-bullet symbol set

  1. my candidate symbol lists
    • hexagrams

      “✡” “⎈” “✽” “✲” “✱” “✻” “✼” “✽” “✾” “✿” “❀” “❁” “❂” “❃” “❄” “❅” “❆” “❇”

    • circles

      “○” “☉” “◎” “◉” “○” “◌” “◎” “●” “◦” “◯” “⚪” “⚫” “⚬” “❍” “○” “⊙” “⊚” “⊛” “∙” “∘”

    • special circles

      “◐” “◑” “◒” “◓” “◴” “◵” “◶” “◷” “⚆” “⚇” “⚈” “⚉” “♁” “⊖” “⊗” “⊘”

    • crosses

      “✙” “♱” “♰” “☥” “✞” “✟” “✝” “†” “✠” “✚” “✜” “✛” “✢” “✣” “✤” “✥”

    • poker sybmols

      “♠” “♣” “♥” “♦” “♤” “♧” “♡” “♢”

    • yinyang

      “☯” “☰” “☱” “☲” “☳” “☴” “☵” “☶” “☷”

    • special symbols

      “☀” “♼” “☼” “☾” “☽” “☣” “§” “¶” “‡” “※” “✕” “△” “◇” “▶” “◀” “◈”

  2. my related org-mode settings
    ;; use org-bullets-mode for utf8 symbols as org bullets
    (require 'org-bullets)
    ;; make available "org-bullet-face" such that I can control the font size individually
    (setq org-bullets-face-name (quote org-bullet-face))
    (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
    (setq org-bullets-bullet-list '("✙" "♱" "♰" "☥" "✞" "✟" "✝" "†" "✠" "✚" "✜" "✛" "✢" "✣" "✤" "✥"))
    

5 select org-ellipsis symbols

  1. my collection of org-ellipsis candidate symbols
    • right arrows

      “↝” “⇉” “⇝” “⇢” “⇨” “⇰” “➔” “➙” “➛” “➜” “➝” “➞”

      “➟” “➠” “➡” “➥” “➦” “➧” “➨”

      “➩” “➪” “➮” “➯” “➱” “➲”

      “➳” “➵” “➸” “➺” “➻” “➼” “➽”

    • arrow heads

      “➢” “➣” “➤” “≪”, “≫”, “«”, “»”

    • other arrows

      “↞” “↠” “↟” “↡” “↺” “↻”

    • lightening

      “⚡”

    • other symbols

      …, ▼, ↴, , ∞, ⬎, ⤷, ⤵

  2. my org-mode settings
    ;; org ellipsis options, other than the default Go to Node...
    ;; not supported in common font, but supported in Symbola (my fall-back font) ⬎, ⤷, ⤵
    (setq org-ellipsis "⚡⚡⚡");; ⤵ ≫
    

6 define the related faces

  1. trick 1: set the variable “org-bullets-face-name”, such that org-mode will use the face-name specified
    ;; make available "org-bullet-face" such that I can control the font size individually
    (setq org-bullets-face-name (quote org-bullet-face))
    
    
    1. Note: org-bullet-face is a face I set up myself. You can set this up using:
(custom-set-faces
 '(org-bullet-face ((t (:foreground "burlywood" :weight normal :height 1.5)))))
  1. trick 2: set the org-bullet-face (I defined this name in the previous line) to have a large font
    (set-face-attribute 'org-bullet-face 
        t :foreground "burlywood" :weight 'normal :height 1.6)
    

7 Appearance of the org buffer after the above configuration

appearance
org-ellipsis-appearance

Author: Da Zhang

Created: 2016-02-15 Mon 02:08

Emacs 25.0.91.1 (Org mode 8.3.3)

 

Implementing pwdw pwdc, a summary of manipulating directory name strings in Emacs lisp

1 Summary

  1. this article summaries several technical tricks for implementing two functions
    • pwdw: copy the dir name of the current buffer (in Windows format) to the kill-ring (clip-board)
    • pwdc: copy the dir name of the current buffer (in cygwin format) to the kill-ring (clip-board)
  2. These two functions are lisp alternatives to my shell functions pwdw and pwdc, for passing the current working directory from cygwin to windows and other programs.
  3. Emacs-lisp code:
    ;; pwdw and pwdc
    (defun pwdw ()
      "Copy the dir name of the current buffer (in Windows format) to the kill-ring (clip-board)."
      (interactive)
      (kill-new (replace-regexp-in-string "/" "\\\\"
                                          (file-name-directory (expand-file-name (buffer-file-name)))))
      )
    (defun pwdc ()
      "Copy the dir name of the current buffer (in cygwin format) to the kill-ring (clip-board)."
      (interactive)
      (kill-new
       (replace-regexp-in-string "\\([a-zA-Z]\\):" "/cygdrive/\\1"
                                 (file-name-directory (expand-file-name (buffer-file-name)))))
      )
    
  4. shell code (compatible with bash and zsh)
    # note: you need -d to convert unix line-ending to dos line-ending for Windows
    alias pwdw='cygpath -w $PWD | tee >(putclip -d)'
    alias pwdc='echo -En $PWD | putclip'
    

2 Technical tricky points in these functions

  1. about path and file names
  2. replace-regexp-in-string: replacing / with \ or c:/ with cygdrive/c
  3. kill-new: to make the text in the kill ring:
  4. about regex in Emacs

Author: Da Zhang

Created: 2016-02-12 Fri 16:54

Emacs 25.0.90.3 (Org mode 8.3.3)

 

How to achieve auto-compilation for the org–>latex–>pdf publishing chain — configurations around latexmk

1 Summary:

  1. how to set up latexmk, a perl program that monitors the status of a tex and run compilation automatically
  2. my Emacs, bash/zsh, and latexmkrc configurations around this tool
  3. my workflow of generating org–>latex–>pdf using this tool
  4. a few notes/tricks

3 installation/configuration of latexmk

  1. no need to install, latexmk is included within MikTex package, CTex, and TexLive
    which latexmk
    latexmk is /cygdrive/c/CTEX/MiKTeX/miktex/bin/latexmk
    
  2. but the INSTALL file in the downloaded package is quite info-rich
  3. check availability and if it is working properly:
    latexmk -v
    

4 Workflow

  1. in the org file, have the following headers (the following uses beamer)
    +LATEX_CLASS: beamer
    
  2. in Emacs, edit org file, then C-c C-e l l to export to latex
  3. open a mintty shell (consolez will not work properly)
    1. type
      latexmk -pvc -pdf -view=none paper.tex
      
    2. a latexmk process will run, and keeps monitoring the status of the tex file “paper.tex”
    3. you can then type
      sumatrapdf -reuse-instance paper.pdf
      
    4. the tex will be automatically compiled into pdf, and sumatrapdf will update the view automatically
  4. why consolez does not work
    1. the $TERM type needs to be xterm-256 or xterm, for properly stopping the latexmk program by typing Control-C
    2. in zsh or bash of consolez, the $TERM is “cygwin”, and Control-C will not work

5 Configurations

  1. my .latexmkrc file in ~
    1. note the default location of .latexmkrc is in your $HOME directory
    2. the language of this configuration file is perl
    3. I specified sumatrapdf as the viewer, because Adobe will lock the file
    4. I added additional extensions for clean_ext
      $pdf_previewer = 'sumatrapdf -reuse-instance %O %S';
      $clean_ext = 'paux lox pdfsync out';
      
  2. my aliases in bash/zsh:
    # for viewing pdf but not locking the file
    alias pdfview='sumatrapdf -reuse-instance'
    
    # for easily use latexmk
    alias mklatex='latexmk -pvc -pdf'
    # -f for non stop
    alias mktex='latexmk -f -pvc -pdf -view=pdf'
    
  3. my set up for different latex classes in init-org:
    (add-to-list 'org-latex-classes
                 '("compact"
                   "\\documentclass [letterpaper, 10pt]{article}
    \\usepackage{fullpage}
    \\usepackage{setspace}
    \\singlespacing
    \\usepackage{times}
    \\usepackage[compact]{titlesec}
    \\titlespacing{\\section}{0pt}{*0}{*0}
    \\titlespacing{\\subsection}{0pt}{*0}{*0}
    \\titlespacing{\\subsubsection}{0pt}{*0}{*0}
    \\usepackage{mdwlist}
    \\usepackage[T1]{fontenc}
    \\usepackage[left=2cm,top=1cm,right=2cm,nohead,nofoot]{geometry}"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\subsubsubsection{%s}" . "\\subsubsubsection*{%s}")))
    
    (add-to-list 'org-latex-classes
                 '("article"
                   "\\documentclass [letterpaper, 11pt]{article}\n
    \\usepackage{fullpage}\n
    \\usepackage{setspace}\n
    \\doublespacing\n
    \\usepackage{amssymb}\n
    \\usepackage{graphicx}\n
    \\usepackage{subfigure}\n
    \\usepackage{float}\n
    \\usepackage{amsmath}\n
    \\usepackage{cite}\n
    \\usepackage{times}\n
    \\usepackage[T1]{fontenc}\n
    \\usepackage[pdfpagemode = colorlinks, pdffitwindow = true, bookmarks = true, pdftoolbar = false, pdfmenubar = true, pdfnewwindow = true]{hyperref}\n
    \\usepackage[left]{lineno}\n"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\paragraph{%s}" . "\\paragraph*{%s}")
                   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
    
    (add-to-list 'org-latex-classes
                 '("beamer"
                   "\\documentclass[red]{beamer}\n
         \\usetheme{Darmstadt}\n
         \\usefonttheme[onlylarge]{structurebold}\n
         \\setbeamerfont*{frametitle}{size=\\normalsize,series=\\bfseries}\n
         \\setbeamertemplate{navigation symbols}{}\n
         \\usepackage[english]{babel}\n
         \\usepackage{times}\n
         \\usepackage[T1]{fontenc}\n
         \\usepackage{graphicx}\n
         \\usepackage{color}\n
         \\usepackage{tikz}\n
         \\usetikzlibrary{arrows}\n
         \\tikzstyle{block}=[draw opacity=0.7,line width=1.4cm]\n
         \\usepackage{listings}
         \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
         frame=single,
         basicstyle=\\small,
         showspaces=false,showstringspaces=false,
         showtabs=false,
         keywordstyle=\\color{blue}\\bfseries,
         commentstyle=\\color{red},
         }\n
         \\institute{BIDMC}\n"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\begin{frame}[fragile]\\frametitle{%s}"
                    "\\end{frame}"
                    "\\begin{frame}[fragile]\\frametitle{%s}"
                    "\\end{frame}")))
    

6 How to run this file as a demo

  1. C-c C-e l l to create the tex file
  2. invoke the latexmk command in a mintty terminal
mktex latex_auto_compilation.tex
  1. open the resultant pdf file in sumatrapdf
pdfview latex_auto_compilation.pdf
  1. change the option line #+LATEX_CLASS:compact, among report, article, MP (not working well now), beamer
  2. repeat step 1 and you will see the latexmk and sumatrapdf working automatically for you.

tabbar mode rocks with customization!

 

 

Why doing this

I like tabbar mode, and it gives Emacs a “modern” feeling – similar to that available in most web browsers such as my
favorite Firefox.

However, I don’t like the default settings of tabbar mode. So here comes my customization:

color and separator

my current tabbar tabs looks:


And the customization code in .emacs file are:

(setq tabbar-background-color "#959A79") ;; the color of the tabbar background
(custom-set-faces
 '(tabbar-default ((t (:inherit variable-pitch :background "#959A79" :foreground "black" :weight bold))))
 '(tabbar-button ((t (:inherit tabbar-default :foreground "dark red"))))
 '(tabbar-button-highlight ((t (:inherit tabbar-default))))
 '(tabbar-highlight ((t (:underline t))))
 '(tabbar-selected ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-separator ((t (:inherit tabbar-default :background "#95CA59"))))
 '(tabbar-unselected ((t (:inherit tabbar-default)))))

key bindings:

I use C-S-< and C-S-> to jump among tabs in the same group, and use C-S-n and C-S-p to switch among groups. Here is the
code in .emacs file:

(global-set-key (kbd "C-S-p") 'tabbar-backward-group)
(global-set-key (kbd "C-S-n") 'tabbar-forward-group)
(global-set-key (kbd "C-<") 'tabbar-backward)
(global-set-key (kbd "C->") 'tabbar-forward) ;; tabbar.el, put all the buffers on the tabs.

my favorite tabbar customization: to toggle between 2 different grouping schemes

  • grouping tabs by major mode (the default)
  • grouping tabs by dir the files belonging to

here is the effect:

  • grouping by dir (see how the org, tex, html, and bbl buffers under the same publishing project are grouped together)

  • grouping by major modes (see how all org buffers are grouped together)

here is the code

(defun tabbar-buffer-groups-by-dir ()
        "Put all files in the same directory into the same tab bar"
        (with-current-buffer (current-buffer)
          (let ((dir (expand-file-name default-directory)))
            (cond ;; assign group name until one clause succeeds, so the order is important
             ((eq major-mode 'dired-mode)
              (list "Dired"))
             ((memq major-mode
                    '(help-mode apropos-mode Info-mode Man-mode))
              (list "Help"))
             ((string-match-p "\*.*\*" (buffer-name))
              (list "Misc"))
             (t (list dir))))))

(defun tabbar-switch-grouping-method (&optional arg)
  "Changes grouping method of tabbar to grouping by dir.
With a prefix arg, changes to grouping by major mode."
  (interactive "P")
  (ignore-errors
    (if arg
      (setq tabbar-buffer-groups-function 'tabbar-buffer-groups) ;; the default setting
        (setq tabbar-buffer-groups-function 'tabbar-buffer-groups-by-dir))))

misc settings

(setq tabbar-cycle-scope (quote tabs))
(setq table-time-before-update 0.1)
(setq tabbar-use-images t)

Date: 2012-09-21

Author: Da Zhang

Org version 7.9.1 with Emacs version 24

Validate XHTML 1.0

LeechBlock – the killer of timekillers

Procrastination, the time-wasting and beating-around-the-bush type of behavior before any progress could be made on the real important things, is very typical among many people, including me.

I found that visiting my favorite websites before I start working is almost irresistible.

From Matt Might’s Productivity tips, tricks and hacks for academics and Boost your productivity: Cripple your technology, I learned about LeechBlock, which is perfect to block my favorite websites during hours I am supposed to work.

I can set up what to block (for example, http://www.cnn.com), when to block (e.g., 0900-1730), how long to block (e.g., 1 min in every hour), what to show when a page is blocked (for me, I used the Journal of Medical Physics website for most recent articles)

To protect the disciplines from being violated, the LeechBlock is actually designed in a quite tricky and clever way:

  • I can set up password to the Option dialog box of LeechBlock for someone else, like my wife, to help them fighting procrastination together;
  • or I can let LeechBlock to require me to type in a 64 or 32 digit long randomly generated combination of letters and numbers before accessing its Option dialog box, which is really a pain. (see the pictures below)

When the path toward surfing online becomes more difficult to approach, it becomes easier for me to resist the desire to do so.

BTW, I don’t think I need to block IE, because I feel that using IE to surf online is as painful as by-passing the control of LeechBlock :-).

Date: 2012-03-25 17:38:16 Eastern Daylight Time

Author: Da Zhang

Org version 7.8.03 with Emacs version 24

Validate XHTML 1.0

My color theme color-theme-dawn-night is updated and uploaded to the marmalade repository (updated)

I have been spending time to tweak and design my own color themes since 2007, and published previous
versions (switch-color-theme-matlab-latex.el) on this blog (https://zhangda.wordpress.com/2009/04/08/my-own-emacs-color-themes-i-use-f6-c-u-f6-to-switch-between-them/).

I think now it’s a good time to move the package to the more popular host, marmalade, so anyone interested could use the
emacs package management tool (package.el) to obtain it. If marmalade is included in your package-archives list (see the
code below for this), you should be able to see the package “color-theme-dawn-night” after firing up list-packages.

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                          ("marmalade" . "http://marmalade-repo.org/packages/")))

You can also download the color-theme-dawn-night.el via http://marmalade-repo.org/packages/color-theme-dawn-night-1.0.el

Here is a brief description of the color theme:

color-theme-dawn-night.el contains two customized color themes:

(1) cl-night
is a dark-background theme, designed for normal programming,
org/muse mode editing and LaTeX editing. The foreground colors are designed
to be somewhat aqua, with a bright and warm feeling.

(2) cl-dawn
is designed with a bright and warm background. The color setup was inspired
by the light yellow background and visual effect of the Matlab programming
environment.

Call function switch-dawn-night to change to the dark face, and call C-u
switch-dawn-night for the bright background face.

Install the theme:
(1)Place color-theme-dawn-night.el into your load-path.

(2)In your .emacs, add:
(require ‘color-theme-dawn-night)

(3)optional keybinding
(global-set-key [f6] ‘switch-dawn-night)

 

One good thing to tweak the color theme is that you can have a full control of the appearance of Emacs. For example, I adjusted different faces of tabbar to make them appear uniformly and as if in a real tabbar system.  Another example is the color of the line numbers on the left fringe — I made them slim and in a “dark gold” color.

Here are some screen shots of my color themes.

color theme dawn night:  night

color-theme-dawn-night: night

color theme dawn night:  dawn

color-theme-dawn-night: dawn

Date: 2012-03-24

Author: Da Zhang

Validate XHTML 1.0

Using org-mode as the ultimate note taking tool (updated)

Whenever there is something important to memorize, I always want to write it down. In fact, Emacs org-mode makes the process easy, pleasant, and in an organized manner. I will use an example to explain how Emacs and org fit into my note-taking process.

I have a dedicated folder containing all my notes, and IT, as one of the most important topic, is a sub-folder. Here is the tree structure of the IT folder.

IT
|-- Acrobat
|   `-- startup_script.org
|-- Emacs
|   |-- debug-lisp.html
|   |-- debug-lisp.org
|   |-- emergency-elisp-steve-yegge.html
|   |-- emergency-lisp.html
|   |-- emergency-lisp.org
|   |-- lisp-programming.html
|   `-- lisp-programming.org
|-- Excel
|   `-- group_formatting.txt
|-- Firefox
|   `-- Firefox Recovery Key.html
|-- HPC
|   |-- Setup_GATE_tool_chain_20100902.lnk
|   |-- bashrc_setup
|   |   `-- bashrc_HPC
|   |-- efficient-way-of-working.html
|   |-- efficient-way-of-working.org
|   |-- tricks.html
|   |-- tricks.org
|   `-- xinhua-hps-bashrc
|-- Linux_commands
|   |-- cat.html
|   |-- cat.org
|   |-- count_files_in_dir.html
|   |-- count_files_in_dir.org
|   |-- find.html
|   |-- find.org
|   |-- find.txt
|   |-- linux_commands.html
|   |-- linux_commands.org
|   |-- scp.txt
|   |-- sed.html
|   |-- sed.org
|   |-- sed_commandline_editor.txt
|   `-- tar.txt
|-- VBA
|   `-- VBA_study_notes.org
|-- X11_cygwin
|   `-- startxwin_of_Xinhua.sh
|-- c++
|   |-- ACM-UNIX-Tutorial-Compiler.html
|   |-- C++Quick-Ref.html
|   |-- C++Std-Lib-Quick-Ref.html
|   |-- Makefiles-short.html
|   `-- gcc-intro.html
|-- cygwin
|   `-- how_to_write_.bashrc_correctly_for_cygwin.org
|-- g++
|   |-- g++compiling.txt
|   |-- gcc&g++.html
|   |-- gcc&g++.org
|   `-- note.txt
|-- gdb
|   |-- debug-tools.html
|   `-- debug-tools.org
|-- latex
|   |-- cygwin_latex_problem.html
|   |-- cygwin_latex_problem.org
|   |-- sumatrapdf-make-emacs_integration.html
|   `-- sumatrapdf-make-emacs_integration.org
|-- make
|   |-- note.html
|   `-- note.org
|-- python
|   |-- math.html
|   `-- math.org
|-- shell
|   |-- bashrc_and_others.htm
|   |-- bashrc_and_others_files
|   |   |-- css_2ad809fd00fb2c1d453a0d2b83bf7b57.css
|   |   |-- ga.js
|   |   |-- gumdrop.png
|   |   |-- index2.jpg
|   |   |-- js_957ff3e13d89532193faea68e21100f9.js
|   |   |-- js_c59e4e9c853d32975fd97f7345ddbabe.js
|   |   `-- show_ads.js
|   |-- notes.html
|   |-- notes.org
|   |-- programming.html
|   `-- programming.org
`-- ssh
    |-- How to set up SSH (for the beginner).pdf
    |-- no_password_access.html
    `-- no_password_access.org

As can be seen, almost every note has two forms: one org file, one html file. The reason that I am showing the IT folder here is to show how I organize my notes through a tree structure representing the hierarchy of related topics.

When I want to take a note, I always think first where does the topic fit into my hierarchal folder systems. Take the Linux command sed for example, I feel like it should be put in IT/Linux_commands/. Thus I enter a emacs function “notes”, which is defined in my .emacs file as

(defun notes ()
  "Switch to my work dir."
   (interactive)
   (find-file "<PATH TO MY NOTES>")
   )

This quickly bring me to my top level dir of all notes, in a dired buffer. Then I quickly follow the hierarchy to IT/Linux_commands/, where I open a file called “sed.org” via [C-x C-f sed.org]

When the file is open, I call another function “make-header”, which I customized from header2.el  for my own purpose. The function will generate a file header for me automatically, here is the result for the sed.org:

#+TITLE: sed
#+AUTHOR: Da Zhang
#+OPTIONS: H:2 num:t toc:nil
#+OPTIONS: ^:nil
#+OPTIONS: <:nil todo:nil *:t ^:{} @:t ::t |:t TeX:t
#how to change image size: #+attr_html: width="40%"

Basically it will do the following:

  1. set the title to be the file name of the buffer, without its parent path and extension;
  2. set up the options for org mode
  3. insert a note for myself about changing the picture size in org-to-html export, which I still did not remember

Then I just start writing down the quick note about sed.

* how to use variable in a sed: use "" instead of ''
CF http://www.unix.com/shell-programming-scripting/14085-how-can-i-use-variable-sed.html
 - example: note the $1 in the double quotes of the 2nd sed
ORG-LIST-END-MARKER

function sortcsvp() {
    cat $1 | sed '1d' | tr -d '"' | sort -n -t, -k 1 | sed "1 i  $1, , " > ./sort-by-protocol/$1;
}

In most cases I will use #+begin_src and #+end_src for enclose any code, for better appearance in the html output.

At the end, I will just press C-c C-e to export the entire buffer to html, which I will view more frequently from Firefox.

To conclude, Emacs and org-mode offered me a comfort environment for systematically taking notes, organize them, and exporting them into beautiful html pages.

————————————————————————————————————————————-

Thanks to Irreal’s comment.
Here is something more I want to add about using org to take notes:

(1) the org-html process is almost perfect if you want to include pictures (for example, taken from your smart phone) in the note. Writing a org file that links to the local picture file using the [[][]] structure is so easy and natural. With the html publication, your output note file contains not only text, but also graphics and pictures that makes the note taking more efficient and direct. I used this feature so often that I need to put the following trick into my org header:

#how to change image size: #+attr_html: width="40%"

(2) the hack of header2.el I talked about making is essentially putting the following lines in header2.el:

(defsubst header-org-mode ()
  "Insert \"#+TITLE: ...\" at the beginning of org file."
  (insert "#+TITLE: " (file-name-nondirectory (file-name-sans-extension (buffer-file-name))) "\n") ;; filename only, without dir or extension
  (insert "#+AUTHOR: " (user-full-name) "\n")
  (insert "#+OPTIONS: H:2 num:t toc:nil\n")
  (insert "#+OPTIONS: ^:nil\n")
  (insert "#+OPTIONS: <:nil todo:nil *:t ^:{} @:t ::t |:t TeX:t\n")
  (insert "#how to change image size: #+attr_html: width=\"40%\"\n"))

Date: 2012-03-24 02:23:35 Eastern Daylight Time

Author: Da Zhang

Org version 7.8.03 with Emacs version 24

Validate XHTML 1.0

SumatraPDF integration in LaTeX-Emacs-make tool chain

 

SumatraPDF integration in LaTeX-Emacs-make tool chain

steps:

1.upgrade to the most recent SumatraPDF http://code.google.com/p/sumatrapdf/downloads/list

2.make sure sumatrapdf is in the search path

3.update make file for the make integration

MAIN=maintex

EPS=img/*.eps

TEX=tomo_spectra.tex 

BIB=da.bib 

REBUILDABLES =  \
*.log   \
*.blg   \
*.bbl   \
*.aux   \
*.lof   \
*.lot   \

LATEXOPTIONS = -src-specials -interaction=nonstopmode

PDFVIEWER = sumatrapdf -reuse-instance -inverse-search "c:\emacs\bin\emacsclientw.exe +%l \"%f\""

BIBDIR = "C:/H/Bib"

BIBOPTIONS = -include-directory=$(BIBDIR)

vpath %.bib /cygdrive/c/H/Bib

viewpdf : $(MAIN).pdf
    $(PDFVIEWER) $(MAIN).pdf &

dvi : $(MAIN).dvi
    yap -1  $(MAIN).dvi

$(MAIN).pdf : $(MAIN).dvi
    pdfclosem $(MAIN).pdf ; dvipdfm $(MAIN).dvi

$(MAIN).dvi : $(MAIN).bbl $(EPS)
    latex $(LATEXOPTIONS) $(MAIN)
        if ( grep 'Rerun' $(MAIN).log > /dev/null ) ; then\
            latex $(LATEXOPTIONS) $(MAIN) ; \
        else :; fi

$(MAIN).bbl : $(TEX)
    rm -f $(MAIN).aux *.bbl; latex $(LATEXOPTIONS) $(MAIN); bibtex $(BIBOPTIONS) $(MAIN) 

clean :
    rm -f $(REBUILDABLES)

4.update .emacs for AucTeX integration

(setq TeX-view-program-list
      '(("sumatra" "sumatrapdf -reuse-instance \"%f\"")
        ("Yap" ("yap -1" (mode-io-correlate " -s %n%b") " %o"))
        ("dvips and start" "dvips %d -o && start \"\" %f")
        ("start" "pdfviewm %o")))

(setq TeX-view-program-selection
      '(((output-dvi style-pstricks)
         "dvips and start")
        (output-dvi "Yap")
        (output-pdf "sumatra")
        (output-html "start")))

if I need inverse search, pub /usepackage{pdfsync} before \begin{document}, or use pdflatex instead of latex

why using sumatrapdf? it does not lock the pdf file, so when restarting the make process, I don’t need to close the pdf file manually.

Date: 2012-02-16

Author: Da Zhang

Org version 7.8.03 with Emacs version 24

Validate XHTML 1.0

tried org2blog mode successfully

Following the blog of Gabriel Saldana “Post to WordPress blogs with Emacs & Org-mode” at http://blog.nethazard.net/post-to-wordpress-blogs-with-emacs-org-mode/#utm\_source=feed&utm\_medium=feed&utm\_campaign=feed I tested the org2blog mode.

The set up is a little different from what was described in the above post: I put the following code in my .emacs file:

(require ‘org2blog-autoloads) (setq org2blog/wp-blog-alist ‘((“wordpress” :url “http://username.wordpress.com/xmlrpc.php” :username “username” :tags-as-categories nil)))

You have to substitute the “username” with your actual username of wordpress.

To use the org2blog, you can M-x org2blog/wp-login first, and then M-x org2blog/wp-new-entry.