Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Lisp by registered user mirko ( 13 years ago )
(require 'cl)

(defvar mirko/beamer-frame-begin "^[ ]*\\\\begin{frame}"
  "Regular expression that matches the frame start")

(defvar mirko/beamer-frame-end "^[ ]*\\\\end{frame}"
  "Regular expression that matches the frame start")


(defun mirko/beamer-find-frame-begin ()
  "Move point to the \\begin of the current frame."
  (interactive)
  (re-search-backward mirko/beamer-frame-begin))


(defun mirko/beamer-find-frame-end ()
  "Move point to the \\end of the current environment."
  (re-search-forward mirko/beamer-frame-end))


(defun mirko/beamer-mark-frame () 
  "Set mark to end of current frame and point to the matching begin.
The command will not work properly if there are unbalanced
begin-end pairs in comments and verbatim environments."
  (interactive)
  (let ((cur (point))
 beg end)
      (setq end (mirko/beamer-find-frame-end))
      (goto-char cur)
      (setq beg (mirko/beamer-find-frame-begin))
      (goto-char beg)
      (set-mark end)))


(defun mirko/beamer-ispell-frame ()
  "Returns the region for the current frame"
  (interactive)
  (save-excursion
    (save-window-excursion
      (mirko/beamer-mark-frame)
      (ispell-region (region-beginning) (region-end)))))

(defun mirko/beamer-indent-frame ()
  "Indent current frame"
  (interactive)
  (save-excursion
    (save-window-excursion
      (save-match-data
 (widen)
 (mirko/beamer-mark-frame)
       (indent-region (region-beginning) (region-end))))))

     

(defun mirko/beamer-frame-index ()
  "Number of frames between end-of current-line and buffer
beginning"
  (interactive)
  (save-excursion
    (save-window-excursion
      (let ((here (line-end-position))
     (frame-index 0))
 (goto-char 0)
 (while (re-search-forward mirko/beamer-frame-begin here t)
   (incf frame-index))
 (message "Frames up to here: %s"
   (number-to-string frame-index))))))

(defun mirko/beamer-goto-frame (frame-index)
  "Move point to beginning of requested frame"
  (interactive "nFrame index: ")
  (catch 'too-few-frames
    (let ((frame-index 0))
      (goto-char 0)
      (while (re-search-forward mirko/beamer-frame-begin nil t)
 (incf frame-index)
 (when (= frame-index frame-index)
   (throw 'too-few-frames t)))
      (message "Buffer has %s frames" frame-index))))



(defun mirko/beamer-toc-kill-frame ()
  "Removes this frame from buffer and puts it into the kill ring"
  (interactive)
  (unless (string= (buffer-name) "*toc*")
    (error "Not in *toc* buffer"))
  (save-excursion
    (reftex-toc-visit-location t)
    (mirko/beamer-mark-frame)
    (kill-region (region-beginning)
   (region-end)))
  (reftex-toc-Rescan))
;;    (goto-line toc-line))))


(defun mirko/beamer-toc-copy-frame ()
  "Puts the contents of this frame onto the kill ring"
  (interactive)
  (unless (string= (buffer-name) "*toc*")
 (error "Not in *toc* buffer"))
  (save-excursion
    (reftex-toc-visit-location t)
    (goto-char (mirko/beamer-frame-end))
    (mirko/beamer-mark-frame)
    (copy-region-as-kill (region-beginning)
    (region-end))))



(defun mirko/beamer-toc-yank-frame ()
  "Yanks the frame from the kill ring BEFORE the current toc entry"
  (interactive)
  (unless (string= (buffer-name) "*toc*")
    (error "Not in *toc* buffer"))
  (save-excursion
      (reftex-toc-visit-location t)
      (goto-char (mirko/beamer-find-frame-end))
      (open-line 3)
      (forward-line 2)
      (yank)))

 

Revise this Paste

Your Name: Code Language: