Emacs: Fixed latex-orgtbl

master
Pierre Neidhardt 2014-03-13 16:13:21 +01:00
parent 4d2c0535fe
commit 74d7fc70c1
4 changed files with 46 additions and 42 deletions

View File

@ -9,6 +9,14 @@ sure it gets executed."
(add-hook hook function)
(funcall function))
(defun calc-eval-line ()
"Append calc expression to end of line after an ' = ' separtor.
Regular math expression can be computed with calc."
(interactive)
(end-of-line)
(insert " = " (calc-eval (buffer-substring-no-properties
(line-beginning-position) (line-end-position)))))
(defun call-process-to-string (program &rest args)
"Call PROGRAM with ARGS and return output."
(with-output-to-string
@ -29,13 +37,26 @@ sure it gets executed."
(progn (goto-char max) (line-end-position))))))
(define-key my-keys-minor-mode-map "\M-;" 'comment-or-uncomment-current-line-or-region)
(defun calc-eval-line ()
"Append calc expression to end of line after an ' = ' separtor.
Regular math expression can be computed with calc."
(defcustom compilation-after-hook nil
"List of hook functions run by `compile-custom'."
:type 'hook
:group 'compilation)
(defcustom compilation-before-hook nil
"List of hook functions run by `compile-custom'."
:type 'hook
:group 'compilation)
(defvar compilation-time-before-hide-window nil
"Hide compilation window after the specified seconds.
If nil, do not hide.")
(defun compile-custom ()
"Run hooks in `compilation-before-hook', then `recompile', then `compilation-after-hook'."
(interactive)
(end-of-line)
(insert " = " (calc-eval (buffer-substring-no-properties
(line-beginning-position) (line-end-position)))))
(run-hooks 'compilation-before-hook)
(recompile)
(run-hooks 'compilation-after-hook))
(defun count-occurences (regex string)
"Return number of times regex occurs in string.
@ -377,6 +398,9 @@ Hook function for skeletons."
(setq skeleton-markers
(mapcar 'copy-marker (reverse skeleton-positions))))
(defvar skeleton-markers nil
"Markers for locations saved in skeleton-positions.")
(defun skeleton-next-position (&optional reverse)
"Skeleton movements through placeholders."
(interactive "P")
@ -394,14 +418,6 @@ Hook function for skeletons."
(pos (goto-char pos))
(t (goto-char (car skeleton-markers)))))))
;; Do not expand abbrevs in skeletons. Not sure it is useful.
;; (setq skeleton-further-elements '((abbrev-mode nil)))
(defvar skeleton-markers nil
"Markers for locations saved in skeleton-positions.")
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
(define-key my-keys-minor-mode-map (kbd "C->") 'skeleton-next-position)
(define-key my-keys-minor-mode-map (kbd "C-<") (lambda () (interactive) (skeleton-next-position t)))
(defun sort-lines-unique ()
"Remove duplicate lines using shell command `sort -u'."
(interactive)

View File

@ -241,32 +241,12 @@
(speedbar-toggle-updates)))
;; Compilation bindings and conveniences.
(defvar compilation-time-before-hide-window nil
"Hide compilation window after the specified seconds.
If nil, do not hide.")
(defcustom compilation-before-hook nil
"List of hook functions run by `compile-custom'."
:type 'hook
:group 'compilation)
(defcustom compilation-after-hook nil
"List of hook functions run by `compile-custom'."
:type 'hook
:group 'compilation)
(require 'functions)
(setq compilation-ask-about-save nil)
(autoload 'recompile "compile" nil t)
(define-key my-keys-minor-mode-map (kbd "<f10>") 'compile-custom)
(define-key my-keys-minor-mode-map (kbd "<f11>") 'previous-error)
(define-key my-keys-minor-mode-map (kbd "<f12>") 'next-error)
(defun compile-custom ()
"Run hooks in `compilation-before-hook', then `recompile', then `compilation-after-hook'."
(interactive)
(run-hooks 'compilation-before-hook)
(recompile)
(run-hooks 'compilation-after-hook))
(add-hook
'compilation-after-hook
(lambda ()
@ -307,6 +287,14 @@ If nil, do not hide.")
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; Skeleton settings
(require 'functions)
;; Do not expand abbrevs in skeletons.
(setq-default skeleton-further-elements '((abbrev-mode nil)))
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
(define-key my-keys-minor-mode-map (kbd "C->") 'skeleton-next-position)
(define-key my-keys-minor-mode-map (kbd "C-<") (lambda () (interactive) (skeleton-next-position t)))
;; Alternate focus.
(add-hook 'occur-hook (lambda () (pop-to-buffer occur-buf)))
;; (add-hook 'help-mode-hook (lambda () (pop-to-buffer (get-buffer "*Help*"))))

View File

@ -55,14 +55,16 @@
(set (make-local-variable 'tex-command) "pdflatex")
;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
(add-hook 'skeleton-end-hook 'skeleton-make-markers)
(local-set-key (kbd "C-c C-a") 'latex-article)
(local-set-key (kbd "C-c a") 'latex-article)
(local-set-key (kbd "C-c C-a") 'latex-insert-table)
(local-set-key (kbd "C-c C-c") 'latex-smallcaps)
(local-set-key (kbd "C-c C-e") 'latex-emph)
(local-set-key (kbd "C-c C-l") 'latex-slanted)
(local-set-key (kbd "C-c C-o") 'latex-orgtbl)
(local-set-key (kbd "C-c C-s") 'latex-insert-section)
(local-set-key (kbd "C-c C-u") 'latex-superscript)
(local-set-key (kbd "C-c l") 'latex-lstinline)
(local-set-key (kbd "C-c u") 'latex-superscript)
(local-set-key (kbd "C-c u") 'latex-usepackage)
(local-set-key (kbd "M-RET") 'latex-itemize)
(turn-on-orgtbl)))
@ -124,11 +126,9 @@ The table type is any value found in `latex-table-names'."
"\\end{" str "}" > \n
"\\end{center}" > \n @)
;; TODO: implement orgtbl directly with latex tables and remove this skel.
(define-skeleton latex-orgtbl
"Insert skel.
TODO: orgtbl broken?
TODO: implement orgtbl directly with latex tables and remove this
skel."
"Insert orgtbl skel."
"Table name: "
> "\\begin{center}" \n
"% BEGIN RECEIVE ORGTBL " str \n

View File

@ -108,7 +108,7 @@ This does not interfere with `subword-mode'."
(local-unset-key key))
(set-face-attribute 'tex-verbatim nil :family "freemono")
(set (make-local-variable 'compilation-scroll-output) t)
(set (make-local-variable 'compilation-hide-window) t)
(set (make-local-variable 'compilation-time-before-hide-window) 2)
(set (make-local-variable 'paragraph-start) "
")
;; (set (make-local-variable 'use-hard-newlines) t)