Not sure why the default configuration was changed in version 23 for the functions that move cursor around like forward-word, backward-word or back-to-indentation. They highlight the words now. Until I figure it out, (it must be a simply variable to set, any idea?, anyone?) a quick and dirty fix to reset to the previous way I liked, is doing:

;; correcting the way forward-word and similar functions work.
I don't want them to highlight text while moving cursor.
(global-set-key (kbd "M-F") 'forward-word)
(global-set-key (kbd "M-B") 'backward-word)
(global-set-key (kbd "M-m") 'back-to-indentation)
(global-set-key (kbd "M-M") 'back-to-indentation)

The simple solution with awk is doing:

awk ‘{print $NF}’

This is useful when like in the following  we want to list just files skipping directories:

ls -l | awk ‘NR!=1 && !/^d/ {print $NF}

There are other options of course, take a look at this example from a nice collection of bash and unix tips

 

 

I’m making a note as I forgot which function was I using after not publishing  anything  for a while

In emacs the function is contained in the package htmlize. This guy made a function to directly have the output code with the css styles inline, as that is necessary when posting in wordpress blogs.

At times it’s necessary to manually force a non-cache reload/refresh of a page, overriding what browsers (wrongly) interpret as when the last change of a site happened. (The cache is a temporary storage area where frequently accessed data can be stored for rapid access in our hard drive.)
To do this in FireFox, hold down SHIFT and click the RELOAD button. In Internet Explorer, hold down CTRL and click the REFRESH button. Other browsers can allow this quick bypass which I was glad to discover, very handy and much simpler than erasing the whole cache. Check these instructions containing others like Safari, Chrome, Konkeror and Flock.

To remove empty lines in a region simply do:

M-x flush-lines RET ^$ RET

or, if blank lines contain some white spaces characters:

M-x flush-lines RET ^\W*$ RET

Whereas with sed (which I use inside emacs via M-| shell-command-on-region ) it’s simply:

sed -e '/^[	 ]*$/d'
(this is either a tab or a space, press the TAB key since most versions
of sed don't recognize the \t character)

How easy is to forget this type of things!

Didn’t know before that “M-x dirs” queries the shell and resyncs Emacs’ idea of what the current directory stack is. Tiny but useful piece of knowledge.

This is more of quick reminder for myself on the difficult task of escaping quotes and running an awk or sed command inside the bash command line. I solved the issue in my case using the octal representation of a single quote (\47), taken from here, where more options are shown.

Having previously accommodated the list of stale links with their replacements in a two columns format that looked like:

http://addressOld.com http://www.goodWorkingOne.com
http://addressOld2.com http://www.goodWorkingOne2.com
etc…

I used the following:

awk '{print "UPDATE library SET url=\47"$2"\47 WHERE url=\47"$1"\47;"}' 

to correctly generated what I wanted sql-postgres statements to update the links table:

UPDATE links SET url='http://goodWorkingOne.com' WHERE url='http://addressOld.com';

Traveling with my kid I had some medication to give him the other night. I didn’t have an alarm clock with me, only my laptop computer. Into the Windows system I found nothing suited to help me gain some rest while waking up again at 3:00 am. I wished Emacs could help, and it certainly didn’t disappoint me once more. I found a simple alarm clock coded by Mathias Dahl here . Great!, I only had to tweak it a little by adding a sound load enough to ring me at the desired time. I picked a rooster sing, which I had collected a while ago when my child was getting to know farm animals. I put a loop around to repeat it a few times so to guarantee the awakening.
Anyways, for what is worth, here goes the cool little snippet:

(defvar alarm-clock-timer nil
  "Keep timer so that the user can cancel the alarm")

(defun alarm-clock-message (text)
  "The actual alarm action"
  (progn
    (let((i 0))
      (while (< i 3)
        (play-sound-file "c:/web/sounds/rooster.wav")
        (setq i (1+ i)))
      (message-box text))))

(defun alarm-clock ()
  "Set an alarm.
The time format is the same accepted by `run-at-time'.  For
example \"11:30am\"."
  (interactive)
  (let ((time (read-string "Time: "))
        (text (read-string "Alarm message: ")))
    (progn
      (setq alarm-clock-timer
          (run-at-time time nil 'alarm-clock-message text)))))

(defun alarm-clock-cancel ()
  "Cancel the alarm clock"
  (interactive)
  (cancel-timer alarm-clock-timer))

Using an interactive shell in Emacs for Windows you might enconter a bug that causes the shell process to terminate when you signal and eof (See point 7.6 here)
If, for example, you try:

/Program Files/Emacs/ cat >newfile
this is a test file
being created with the cat command
directly from the user input 
in shell.

Now, by pressing C-d (or C-c C-d) the input should finish here, and the prompt return, but what happens instead, is that the shell process terminates. Same thing occurs if you try to M-x comint-send-eof or if you pick an eof signal from the menu.

I had noticed that before (in my Windows emac, only not under Unix), but last night I found that an eof sign could be generated by typing C-q C-z.

I choose to set an alias and bind it to some keys in my .emacs to overcome the issue:

(defalias 'eof
  (read-kbd-macro "C-q C-z RET"))
(global-set-key [M-S-f8] 'eof)

Of course a better solution would be to advice the comint-send-eof to procede accordingly when in emacs for Windows. Anybody knows how to do it, or mind to share a stronger fix than this hack? Any feedback will be appreciated.

Update:
Actually there’s no need to set an alias, as I learned that this is also possible and more straight-forward:

(global-set-key [(meta shift f8)]
 '(lambda () (interactive) (execute-kbd-macro((read-kbd-macro "C-q C-z RET")))))

Knowing how to do loops in awk is helpful to address a range of fields. If for example, we want to output only from second, to prior to last field. Say we’ve got :

one:two:three:four:five:six:seven:eight:nine

Fields are here defined by “:” separator, so using:

awk -F ':' '{for(i=2;i<NF;i++) printf "%s:",$i}'




We will get:

two:three:four:five:six:seven:eight: