Thursday, March 27, 2008

linux: open pdf within a browser window AND how to browse e-books from NetLibrary

Lots of interesting e-books from our SFU library are based on the site of www.netlibrary.com . The readers have to go to the online lib. However, the NetLib didn't provide Linux users about their reader softerware (only for windows users). I notice that essentially when one reads an e-book online, it is a pdf file downloaded (only one page each time). No need special reader at all! However, my browser cannot open pdf file within a browser window so that I have to click a diagostic window to save it or read it by certain pdf software. If I can read pdf files within the browser, then the life becomes simpler. No need to open the pdf file each time, just read the book in the browser! I tried some approaches by following instructions on the internet. Finally I solve the problem. I think the essential steps are also useful for windows users.

- type : about:plugins in your web address blank line to see if acrobat reader plugins over there. If not, see the next
- try to find the lib file which should be located in the directory where acrobat reader is installed, in my case, it is:

/opt/Adobe/Reader8/Browser/intellinux/nppdf.so . copy it over to the directory where

firefox is installed, in my case,

/home/myusername/.mozilla/plugins/

- check about:plugins again. If not, read the next line.
- re-initialize the data base, remove files pluginreg.dat where your firefox is installed.
- I guess the problem should be solved. I refer to the web page here:

http://support.mozilla.com/en-US/kb/Opening+PDF+files+within+Firefox

Sunday, March 9, 2008

Emacs: how to auto-complete word

Both vim and emacs have a function to auto-complete words. For example, in emacs, type "M-/" then it will help you automatically complete the word currently you are typing in. This specially is useful as programming.

Also, I find a good file to compare commands in vim and emacs. In order to avoid the original page is dead, I post it here for reference. The original address is: http://karl-voit.at/vim-emacs-cheatsheet_of_freezing_hell.txt

,----
| emacs-stamp: Time-stamp: <2006-11-07>
| vim-stamp: Latest change: Wed Nov 07 15:34:18 CET 2007
| .... whichever comes last *ggg*
|
| Title: vim7-emacs21-cheatsheet of freezing hell
| ... tries to combine the two editors of choice
|
| Author: Karl Voit
| Purpose: learn emacs21 _and_ vim (for myself)
| License: Creative Commons http://creativecommons.org/licenses/by/2.5/
| Status: constantly modified and enlarged
`----

================================================================================
Editor shortcuts: Emacs and vim vim emacs21
================================================================================

exit :q C-x C-c
save :w :w! C-x C-s
save as :w

save and exit :wq (or: ZZ)
exit without saving :q! (or: ZQ)

open file :e(dit) file C-x C-f
open file read only C-x C-r
re-read file (discard changes) :e(dit)!

edit file under cursor gf (goto file)

undo last changes u (or: C-_) C-_
undo one change :u(ndo)
undo latest changes on current line U
redo C-r

repeat last change .

append text after cursor a
append text after EOL A

insert text after cursor i
insert text before first non-whitesp. I

insert line below cursor and insert o
insert line above cursor and insert O

mark char begin v (column: C-v|C-q) C-Space
mark line begin V

restore last selection gv

copy marked part y M-w
paste marked part p C-y "yank"
cut marked part c C-w
delete marked part d

delete char x DEL
delete line dd (or: :d)
copy current line yy (or: Y)
delete to end of word cw (change word) M-d
delete current word caw
delete to EOL D C-k

toggle overwrite/insert mode INS (or: R) M-x overwrite-mode
replace current char with r

repeat next X times X C-u X

complete word M-/
complete word backward C-P M-/
complete word forward C-N M-/

cancel C-c C-g

redraw C-l

file info C-g
file info (verbose) g C-g

set auto indent :set ai M-x auto-fill-mode
:set textwidth=0

execute shell code :r(ead) !

show whitespaces :set list

insert :r(ead) M-x insert-file

--------------------------------------------------------------------------- Help

show help of cmd XY :help XY
show man-page of current word K
grep help :helpg foobar

------------------------------------------------------------------------ Buffers

close buffer C-w c :clo(se) C-c k
close all buffers but current C-w o :on(ly)

open file for writing C-x C-f
open file for reading C-x C-r

change to previous buffer C-^ C-6 C-x b
change to buffer number <12> <12> C-^ <12> C-6 C-x b
:b <12>
split vertically C-w s :sp(lit)
split horizontally C-w v :vs(split)

duplicate buffer :new

change to (upper) high buffer C-w h
change to lower buffer C-w l

list buffers :ls

--------------------------------------------------------------------- Navigation

goto line <12> <12>G M-x goto-line <12>

up k C-p
Cursor movements left right h l C-f C-f
down j C-n

buffer begin 1G gg M-<>

line begin ... end 0 ... $ C-a ... C-e
line begin (first non-whitespace) ^

word next w M-f
word last b M-b

sentence previous ( M-a
sentence next ) M-e

paragraph begin { M-{
paragraph end } M-}

goto last place C-o
goto next place (if any) C-i

goto begin of last marked part '<>

page up C-b M-v
page down C-f C-v

1/2 page up C-u
1/2 page down C-d

scroll one line down (keep cursor) C-e
scroll one line up (keep cursor) C-y

remember position (as p) m p C-x r m
jump to position (p) ` p C-x r b
jump to last marked position ``
jump to last place edited `.
list all marked positions :marks

place current line in the center z. C-l "locate"

------------------------------------------------------------ Search and replace

current line: goto character X fC
current line: goto character X backw. FC
current line: go before character X tC
current line: go before char. X backw.TC

activate incremental search :set incsearch
search incremental (if activated) / C-s
search incremental backwards (if activated) ? C-r
repeat search n C-s or C-r
repeat search in other direction N

replace s/foo/bar(/gci) M-%

search word under cursor *
search word under cursor backward #
search local variable under cursor gd
search buffer variable under cursor gD

search correspondent brace/bracker/.. %

unhighlight the search patterns :noh

search for regular expressions /REG C-M-s
repeat search for reg. expr. n C-M-s
search in other directory for reg.ex. N C-M-r

--------------------------------------------------------------------- Formatting

lowercase current word :map l viwuW M-l
capitalize current word :map c viwu~W M-c
uppercase current word :map u viwUW M-u
toggle case of current word :map t viw~W
toggle case of char under cursor ~

quote text C-c C-q
format line
format paragraph gqap M-q
format whole document gggqG

shift marked lines to left <<>>
set shiftwidth :set shiftwidth=4


------------------------------------------------------------------------- Macros

begin recording (name: foo) qfoo C-x (
end recording q C-x )

execute macro foo @foo C-x e
repeat macro execution @@

edit macro "ap
end edit macro

save macro

------------------------------------------------------------------------ Columns

mark column begin C-v (Windows: C-q) C-space

set width mark to longest line $

copy column(s) "*y
paste column(s) p C-x r y "yank"
cut column(s) d C-x r k "kill"

insert column text (foo) (visual:) Ifoo ESC C-x r t foo

-------------------------------------------------------------- Folding / Outline

hide all zC C-c C-t
show all zO C-c C-a
toggle hide/show all zi

hide this zc C-c C-d
show this zo C-c C-s

goto previous zk C-c C-p
goto next zj C-c C-n

------------------------------------------------------------- Special Characters

enter carriage return C-q ENTER C-q ENTER
enter newline C-q C-j C-q C-j
enter spoiler character ^L C-q C-l C-q C-l

------------------------------------------------------ Compare/merge differences

start file A and B in compare mode vimdiff A B emerge A B

emacs: goto fast-mode (C-c C-c doesn't have to be used) C-c C-c f
emacs: goto edit-mode e

next difference ]c (C-c C-c) n
previous difference [c (C-c C-c) p
goto difference X C-u X j

change to left file (higher) C-w h
change to right file (lower) C-w l

take this version :[range]diffpu(t) dp
take other version :[range]diffg(et) do

take A-version (C-c C-c) a
take B-version (C-c C-c) b

quit without saving the merge C-]
recenter buffers l

emacs: http://www.cs.cmu.edu/cgi-bin/info2www?(emacs)Merge%20Commands

---------------------------------------------------------------- Version Systems

vim: install vcsnursery from http://www.vim.org/scripts/script.php?script_id=1898

commit changes :VCSCommit C-x v v
show differences between versions :VCSVimDiff C-x v =
show log of current file :VCSLog C-x v l
revert changes to most recent version :VCSRevert C-x v u
update current file from repos :VCSUpdate

add file to repos :VCSAdd C-x v i
show annotations :VCSAnnotate
delete file (incl. from repos) :VCSDelete
show difference to previous version :VCSDiff
view a certain version :VCSReview 42 C-x v r
show detailed infos :VCSStatus


================================================================================
vim specific shortcuts:
================================================================================


================================================================================
Own vim macros
================================================================================

" move line before boxquote into title field of boxquote
map ,vkbqt kDj6lp0

" remove/delete trailing whitespace:
nmap ;tr :%s/\s\+$//
vmap ;tr :s/\s\+$//

"kill quoted sig
map ,kqs G?^> -- $d}

" change subject (Subjectaenderung) (Source: Michael Prokop)
map ,vkcs :set nohlsearch
\:1,/^Subject: /g//s/^\(Subject: \)\(Re: \)\=\(.*\)$/
\\1 (was: \3)/9i

" simple quote (insert quote after this line)
map ,vksq 0jikki

" quote between line (insert quote in between the line)
map ,vkqbl i0kxkkxjxi

" update timestamp (make sure that "set paste" is NOT set
iab Tue Jul 31 13:03:52 CEST 2007 =strftime("%a %b %d %T %Z %Y")
" map ,L 1G/Latest change:\s*/e+1CYDATE
map ,L 1G/Latest change:\s*/e CYDATE

" voit 20070306:
" ESC-c ... capitalize current word (and goto next word)
map c viwu~W
" ESC-l ... lowercase current word (and goto next word)
map l viwuW
" ESC-u ... uppercase current word (and goto next word)
map u viwUW



FIXXME: Bereichsangaben

" Using (g)vim to colorize sourcecode (from: http://barnson.org/node/295#comment-26758)
" used here: Visual Basic syntax
:cal SetSyn("vb")
:syntax on
:set background=light
:runtime! syntax/2html.vim
ggVG (to select all in this top frame)
"+y (to copy to clipboard)


...................................................................
...................................................................
...................................................................
...................................................................
...................................................................
N O T E S F O L L O W I N G
...................................................................
...................................................................
...................................................................
...................................................................
...................................................................

Svens Vortrag:
------------------------------------------------------------------------- Suchen


------------------------------------------------------ Eingabe von Sonderzeichen

Eingabe über ASCII-Nummer:
ß 223 ä 228 ö 246 ü 252

Zwei-Zeichen-Kombination:
Digraph Input! a + : -> ä

automatische Einrücken (indenting)
Clipboards/Register
Markieren von Text
von Position bis Position
zeilenweise (block)
als Rechteck -> Tabelle

Zeile? DOS/Windows, Unix, oder Mac?
Automatische Erkennung
Beliebige Wahl

%page
Anzeige - Grundlegend

Aktuelle Position des Cursors (Lineal,ruler)

%pause
ASCII-Wert von Zeichen

%pause
Sichtbarmachung von speziellen Zeichen
(TABs, trailing spaces)
:set list -> schon oben drinnen

%pause
geteilte Fenster (horizontal,vertikal)
-> TextKopieren, Vergleiche

%page
Anzeige - Fortgeschritten

Syntax Coloring / Highlighting
%pause
Achtung: ersetzt keinen Parser!

%pause
Struktur der Datei anzeigen - Baumstruktur
Text verstecken
Syntax dependant
Kommandos zum Einklappen und Verstecken

%page
Abkürzungen - Abbreviations

%pause
einfache Wortexpansion:
LS -> Leutheuser-Schnarrenberger

%pause
mehrere Worte:
LT -> Linux-Tag Chemnitz

%pause
mehr als nur Buchstaben:
function_mit_viel_bedeutung(*par1,par2)
* = neue Cursorposition

%pause
mehrzeilige Floskeln:

Sehr geehrter Herr Spammer..
..Aufnahme ins Killfile..
Gründe: [Liste]
Mit freundlichen Grüßen

%page
Goodies

Autosave
Backup files
Compiler
Filtering
Sessionfile
Syntax Input

%page
Grenzen - Limits

Endlicher Speicher -> Grenzen

Dateigröße
Dateinamenlänge
Displaybreite

Zeilenlänge
Zeilenanzahl

Bufferanzahl
Registergröße

,----
| 2do
`----

tabs (vim7)

retab + ersetzen:
:set tabstop=4
:set expandtab
:%retab

^M herauslöschen

align-current


query option value :set OPTION?

folding + examples (emacs-2do-list and vim-2do-list)

mika@grml ~ % grep boxes .vimrc
" 040420 introduced history 8-) and slightly modified 'boxes'-stuff
" 030219 VBlockquote.vim - like the tool "boxes" works ;-)
" 030219 Call boxes - with some funny box-styles ;o)
map ;0 :'<,'>!boxes
map ;1 :'<,'>!boxes -d boxquote
map ;2 :'<,'>!boxes -d peek -a c -s 40x5
map ;3 :'<,'>!boxes -d c-cmt
map ;4 :'<,'>!boxes -d dog -a c
map ;5 :'<,'>!boxes -d simple -a
jr
map ;6 :'<,'>!boxes -d headline
--> Test! (FIXXME)
--> boxes = extra-tool!

"boxing" text C-c q
title of box C-c w

Snippets einfügen wie zB :
:he :iabbrev
:he mapmode-i
(Vim7: C-x C-o)

Ranges: . .+3 % ,. .,$


.........................................................

,----
| notes from a former talk:
`----
:set tw=50 ... set texxt width
map gqip ... macro setzen
:set ft=html
:set paste ... Einfuegen ohne Umformatierung
:set nopaste ...
:set sw ... Option vervollstaendigen lassen
:set sw= ... Option plus Wert vervollstaendigen lassen
:set listchars=tab:»·,trail:·,,eol:$ ... wie sollen list-Elemente usw visualisiert werden?
:w datei:.neu ... Kopie mit Anhaengsel ".neu" erstellen, Buffer bleibt bei "datei"
:!ls -l % ... shell-Kommando ls aufrufen (%=aktueller Buffername)
:! ... letzter Befehl, der mit "!" begonnen hat
C-w n ... C-w=Fensterbefehl, n=new
C-w C-r ... unterster Buffer oben einfuegen (rotate)
:help C-v C-w ... show help on windows-commands (C-v nur um C-w einzugeben)

vimdiff
:diffget ... Aenderungen in den Buffer uebernehmen

%%% vim: ft=mgp ai noet ts=2

------------------------------------------
Emacs und ispell:

;; User-Dictionary ohne Nachfrage speichern
(setq ispell-silently-savep t)
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checking" t)
(autoload 'flyspell-mode "flyspell" "On-the-fly ispell." t)
(setq ispell-program-name "aspell")

;; Initialize spell checking
(setq-default ispell-program-name "aspell")
(set-default 'ispell-change-directory "ndeutsch8-15")
(set-default 'ispell-local-dictionary "ndeutsch8-15")
;; ========================
;; ISPELL
;; ========================
(require 'ispell)
(add-to-list 'ispell-dictionary-alist
'("ndeutsch8-15"
"[a-zA-Z\304\326\334\344\366\337\374]"
"[^a-zA-Z\304\326\334\344\366\337\374]"
"[']" t
("-C" "-d" "german")
"~latin1" iso-8859-15))

;; ========================
;; ISPELL End
;; ========================

;; ========================
;; FLYSPELL
;; ========================
(add-hook 'flyspell-mode-hook
(function (lambda ()
(setq ispell-local-dictionary "ndeutsch8-15")
)))


M-X change-ispell-dictionary

-----------------------------------------------------------
emacs und LaTeX

Added in file c:\.emacs

(require 'tex-site)
(setq tex-dvi-view-command "C:\texmf\miktex\bin\yap.exe")
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(TeX-output-view-style (quote (("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f") ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)?\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^a5\\(?:comb\\|paper\\)?$" "^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^a5\\(?:comb\\|paper\\)?$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d") ("^dvi$" ("^landscape$" "^pstricks$\\|^psfrag$") "%(o?)dvips -t landscape %d -o && gv %f") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$" "^landscape$" "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "." "%(o?)xdvi %dS %d") ("^pdf$" "." "\"c:\\Programme\\Adobe\\Acrobat 6.0\\Reader\\AcroRd32.exe\" %o") ("^html?$" "." "netscape %o")))))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)


Change target to PDFLaTeX: C-c C-t C-p
Compiled using C-c C-c



=== [ ENDE ] === ------------------------------------------------------------------------------
%%% Local Variables:
%%% mode: outline
%%% outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[.+\\]\\)? .*\\)\\|\\(^=== \\[ .* \\] ===.*\\)"
%%% eval: (auto-fill-mode -1)
%%% eval: (flyspell-mode -1)
%%% eval: (end-of-buffer)
%%% eval: (hide-body)
%%% emerge-set-combine-versions-template: "%a\n%b\n"
%%% End:
%%% OLD-outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[\\(maggie\\|lisa\\)\\]\\)? .*\\)"
%%% OLD-outline-regexp nur "[][] Text": "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\] .*\\)"
%%% OLD-outline-regexp inkl. Sterne als Items: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\] .*\\)\\|\\(*+ \\)"

Locations of visitors to this page