Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 22nd, 2011  |  syntax: Lisp  |  size: 0.76 KB  |  views: 106  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (defun my-column-ruler (width)
  2.   "Display temp ruler at point."
  3.   (interactive `(,(- (+ (window-hscroll)(window-width)) 1)))
  4.   (momentary-string-display
  5.    (if (< width 10)
  6.        "1   5   10\n|...|....|\n"
  7.      (let* ((iterations (/ width 10))
  8.             (short (- width (* 10 iterations)))
  9.             (result1 "|...|....|")
  10.             (result2 "1   5   10")
  11.             (inc1 "....|....|")
  12.             (inc2 "        %d0")
  13.             (i 1))
  14.        (while  (< i iterations)
  15.          (setq i (1+ i))
  16.          (setq result1 (concat result1 inc1))
  17.          (setq result2 (concat result2 (substring (format inc2 i) -10))))
  18.        (concat result2 "\n" result1 (substring inc1 0 short) "\n")))
  19.    (line-beginning-position)
  20.    nil "[space] Clears ruler"))
clone this paste RAW Paste Data