A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

Debugging Perl in Emacs

Notes only:

  • http://search.cpan.org/~yewenbin/Emacs-PDE-0.2.16/lib/Emacs/PDE.pm
  • http://www.emacswiki.org/emacs/PerlLanguage
  • http://www.emacswiki.org/emacs/CPerlMode
  • http://cpansearch.perl.org/src/YEWENBIN/Emacs-PDE-0.2.16/lisp/doc/QuickStartEn.html

Emacs for a vi user

In the past I've exclusively used vi, but now I want to use Emacs as I've heard it has some useful modes, for example 'font-lock-keywords' mode which is one way to easily highlight certain keywords in a program's console output. I don't want to mess around compiling specialised text highlighting programs, and they're not in my standard repos. Emacs is much more likely to already be available wherever I need it.

Emacs commands:
  • To exit: C-x C-c
  • Turn on syntax highlighting: M-x font-lock-mode

Key:
C = Ctrl
M = Meta (Alt)

Thanks to the rest of the web

UPDATE: It turns out font-lock-keywords can easily be implemented in a 3 line bash script. Call it "highlight":

    # Usage: tail -f error.log | highlight "error"
    RED="$(tput setaf 1)"
    RESET="$(tput setaf 7)"
    sed "s/$1/$RED$1$RESET/"

But I would still like to see the Perl debugger integrated into Emacs

Setting up xemacs xslt-process mode

I set all these options in the environment:

#########################
# copied from /etc/java/java.conf
# JPackage Project
#########################
# Location of jar files on the system
export JAVA_LIBDIR=/usr/share/java
# Location of arch-specific jar files on the system
export JNI_LIBDIR=/usr/lib/java
# List of known java homes (used for autodetection if none is provided)
export JAVA_HOME_LIST=$JAVA_LIBDIR-utils/java_home.list
# Root of all JVM installations
export JVM_ROOT=/usr/lib/jvm
# Default jvm
export JAVA_HOME=$JVM_ROOT/java
# Options to pass to the java interpreter
export JAVACMD_OPTS=
#########################


export CLASSPATH=/usr/share/java

Now when I try to run xslt-process, it says:
Starting the BeanShell. Please wait...

...but then straight away it still always says:
Could not process file, most probably (Xalan1|Saxon) could not be found!

What I think is happening:
  • xalan-2.4.1.jar is installed, not xalan1 as is required.
  • Not all of saxon's dependencies are installed.

Working with xemacs XSLT-process mode

M-x xslt-process-mode - enable xslt-process mode
C-c C-x v - run the xslt processor and view results (be sure to type slowly enough!)

M-x customize-group RET xslt-process - options menu: change engine, customise key bindings, etc.

NOTE: the default run command above may have problems under cygwin. Redefine it to C-x C-c C-v and it should work.

xemacs buffer control

C-x b [buffer] [enter] - select or create a named buffer
C-x C-b - list existing buffers
C-x 1 - close the buffer list

Emacs and Cygwin

Can't quit emacs from cygwin?

From within Cygwin, if you start xemacs with: xemacs -nw (for No Window), then C-x C-c to quit emacs does not work. Instead you must type C-g to exit.

xemacs mode line

How to interpret the status line in xemacs:
http://www.xemacs.org/Documentation/21.5/html/xemacs_4.html#SEC10

GNU info

navigate within info screens:














bgo to beginning of the page
?help
mchoose a menu item from the current page (has tab completion)
fchoose a cross-reference to follow (tab completion)
f?list all cross-references on the current page
lgo back to last page

Ctrl-gcancel menu command
isearch index for topic
ddirectory of all info pages
tgo to 'top' of current manual
ssearch forward
qquit info screen

Emacs

Emacs is desirable for its XSLT debug mode, Emacs::PDE, and font-lock-keywords mode

Viper is a full-featured Vi emulator for GNU Emacs and XEmacs. But if you don't use that, keep reading.

Emacs notes, from the perspective of a vi user

Problems:

* The manual calls for C-h (Ctrl-h) to be used as a special command
** but when using Putty from Windows, by default Ctrl-h just does a backspace.
** from Windows, it can't tell the difference between Ctrl-H and the backspace key
** This means if you re-map Ctrl-H, it also re-maps the Backspace key. I haven't solved this yet.

--------------------------------------------------------

To read the manual on key commands:

1) type F1, i - gets you to the info menu
2) type m, emacs, [enter] - takes you to the Emacs info file
3) Page down to "Fundamental Editing Commands", "Important Text-Changing Commands", etc. and press [enter] on the menu items you want (typing lowercase L takes you

'back' one page)

--------------------------------------------------------

Notes:

* Terminology: C-x means Ctrl-x, C-M-x means Ctrl-Meta-x - the Meta key is Alt under MS Windows)
* For some commands, holding Ctrl is required for the second character (e.g. quit: C-x, C-c), and for others commands it's not (e.g. undo: C-x u)
* Commands like this "M-x set-visited-file-name" mean: type Meta-x, then type the string 'set-visited-file-name'.
* After typing M-x you can also use tab-completion to find commands.

Translation of common Emacs commands for vi users:

commandviemacs

save file:wC-x C-s
save & exit read-only file:wq!C-x, C-c, follow prompts
save to a different file:w fooM-x set-visited-file-name
find a file to open
C-x C-f

delete to end of lineShift-dC-k

undouC-x u

uC-_ (hold Ctrl, press dash/hypen/underscore key)
redorbreak out of undo mode, and type C-_ again

note: these searches are case insensitive
search forward/C-s (incremental / search-as-you-type)

/C-s, [enter] (non incremental / type whole word, then search)
search backward?C-r (incremental)

?C-r, [enter] (non incremental)

note: even these *regex* searches are case insensitive. There is a way to make them case sensitive: set the variable `case-fold-search' to `nil'.
search forward using regex
C-M-s (incremental)
and backward
C-M-r


call out to the shell!M-! (Meta-Shift-1)
start a full subshell
M-x eshell


Notes on differences to vi:

* undo commands wrap around. Once you undo all your edits, the undo command reverses direction and starts re-doing the edits! break out of the undo mode and press C-_ (undo) again to change the direction of undo/redo command.

* files are autosaved to a seperate buffer. to recover after a crash, type: M-x recover-file foo.c


Emacs-only commands:

list commands in help menuF1, ?
get help on key combinationsF1, k, [some key combination]
toggle read-only status of the bufferC-x, C-q
get out of a commandC-g
redo an edit (undo the undo)type any harmless character to break out of undo mode. You will now be able to undo your undo commands.

remove help windowC-x 1
scroll the helpC-M-v

re-map a keyM-x global-set-key [enter]