Results tagged “emacs lisp” from SweetFriday

Emacs: Org-mode WikiPedia links

|

The other day I was going through some notes that I organize using Org-mode and I realized that it's a pain in the ass to write up links to Wikipedia entries all the time. So I whipped up some code that adds an org-mode link.

Emacs Poetry Snippet

|

The following is a snippet for LaTeX mode in Emacs. The snippet uses the wonderful YASnippet package and inserts the date of the poem being written and a tiny bit of LaTeX around it.

;; LaTeX snippets
(yas/define-snippets
  'latex-mode ; Snippet is available when in LaTeX mode
  '(
    ("poem" ; Keyword that will trigger the snippet
     ; The snippet itself
     ; (Each newline can be replaced with \n to make the snippet fit on one line)
     "\\begin{verse}
\\poemtitle{${1:untitled}}
% Written on ${2:$(format-time-string \"%e %B %Y\")}
$0

\\end{verse}
"
     "begin verse ..." ; Name of the snippet
     nil)
  )
)

Here's a function for Emacs that counts the number of words in a buffer by using a regular expression:

(defun wc ()
  (interactive)
  (message "Word count: %s" (how-many "\\w+" (point-min) (point-max))))

The regular expression matches against one or more word characters. It doesn't move the current point of the buffer so you don't have to keep re-positioning the cursor every time you run this function.

The reason I'm posting this is because I was searching for something like this and everyone keeps suggesting to use the "wc" shell command while in Linux, but I'm in Windows! How can I use it? Another thing I found is that people write up functions that loop through words and count them. I'm guilty of doing that, but using the above function is much much easier.

Emacs has most everything that you can think of. The problem is that it's all hidden away somewhere and you have to take the time to dig around.

Update: The how-many function is defined in replace.el. To find out more about it, press C-h f how-many RET.

Find recent content on the main index or look in the archives to find all content.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by Movable Type 4.1