[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] Re: Contribution to AUCTeX
From: |
Vincent Belaïche |
Subject: |
[AUCTeX-devel] Re: Contribution to AUCTeX |
Date: |
Sun, 13 Jun 2010 08:41:26 +0200 |
> From: address@hidden
> To: address@hidden
> CC: address@hidden; address@hidden
> Subject: Re: Contribution to AUCTeX
> Date: Sat, 12 Jun 2010 19:49:28 +0200
>
[...]
>
> I've now changed `Texinfo-find-env-end' and `Texinfo-find-env-start' to
> work like the respective commands in LaTeX and ConTeXt mode. This
> should be a cleaner approach compared to dealing with the differences in
> all calling functions.
>
> Unfortunately this means you will have to produce another patch. It
> should likely be similar to your last one, i.e. include
> `Texinfo-mark-environment' as a copy of `LaTeX-mark-environment' adapted
> for Texinfo mode. I thought about providing a joint implementation for
> both modes, but it likely makes things more complicated than an adapated
> copy. Perhaps one can point out the origin of the implementation in a
> comment.
>
Well I don't see why a common implementation would make things more
complicate, now the Texinfo flavour is almost identical to its LaTeX
counterpart but for the find begin/end functions.
I think that starting with a plain copy is fine, just to see what
happens (is there going to be some divergence...), but there should be
a merge/code factorization at some point in time.
I added a TODO comment in that direction next to the mark environment
function.
> By the way, please use auctex-devel for such patches. I'm cross-posting
> this message to the auctex and auctex-devel lists and set a
> Mail-Followup-To header to auctex-devel. In case it gets mangled on the
> way to you please follow up to auctex-devel manually.
>
OK, please note that I am not subscribed to the auctex-devel, only to
the AUCTeX main list, so please add me explictely to recipient for any
subsequent email exchange.
Vincent
> --
> Ralf
*** tex-info.el.old Sun Jun 13 04:54:51 2010
--- c:/Programme/GNU/emacs-extension/lisp/auctex/tex-info.el Sun Jun 13
05:31:02 2010
***************
*** 52,61 ****
("verbatim") ("vtable"))
"Alist of Texinfo environments.")
(defconst texinfo-environment-regexp
;; Overwrite version from `texinfo.el'.
(concat "address@hidden("
! (mapconcat 'car Texinfo-environment-list "\\|")
"\\|end\\)\\>")
"Regexp for environment-like Texinfo list commands.
Subexpression 1 is what goes into the corresponding address@hidden'
statement.")
--- 52,79 ----
("verbatim") ("vtable"))
"Alist of Texinfo environments.")
+
+ (defconst Texinfo-structuring-command-levels-alist
+ '( ("top" . -1) ("chapter" . 0) ("unnumbered" . 0) ("appendix" . 0)
+ ("majorheading" . 2) ("chapheading" . 2)
+ ("section" . 5) ("unnumberedsec" . 5) ("appendixsec" . 5) ("heading" . 5)
+ ("subsection" . 9) ("unnumberedsubsec" . 9) ("appendixsubsec" . 9)
("subheading" . 9)
+ ("subsubsection" . 13))
+ "Alist providing for each strucuting command the corresponding
+ level starting by -1 for @top, down to 13 for @subsubsection." )
+
+
+ (defconst Texinfo-structuring-command-re
+ (concat "^\\s-*@"
+ (funcall 'regexp-opt (mapcar 'car
Texinfo-structuring-command-levels-alist)
+ 'word))
+ "Regexp to match structuring commands")
+
+
(defconst texinfo-environment-regexp
;; Overwrite version from `texinfo.el'.
(concat "address@hidden("
! (regexp-opt (mapcar 'car Texinfo-environment-list))
"\\|end\\)\\>")
"Regexp for environment-like Texinfo list commands.
Subexpression 1 is what goes into the corresponding address@hidden'
statement.")
***************
*** 160,165 ****
--- 178,301 ----
(goto-char (match-beginning 0))
(error "Can't locate start of current environment")))))
+
+
+ (defun Texinfo-mark-environment (&optional count)
+ "Set mark to end of current environment and point to the matching begin.
+ If prefix argument COUNT is given, mark the respective number of
+ enclosing environments. The command will not work properly if
+ there are unbalanced begin-end pairs in comments and verbatim
+ environments."
+ ;; TODO:
+ ;; This is identical to the LaTeX counterpart but for the find begin/end
+ ;; functions. So some day the implemenation should be factorized.
+ (interactive "p")
+ (setq count (if count (abs count) 1))
+ (let ((cur (point)) beg end)
+ ;; Only change point and mark after beginning and end were found.
+ ;; Point should not end up in the middle of nowhere if the search fails.
+ (save-excursion
+ (dotimes (c count)
+ (Texinfo-find-env-end))
+ (setq end (line-beginning-position 2))
+ (goto-char cur)
+ (dotimes (c count)
+ (Texinfo-find-env-start)
+ (unless (= (1+ c) count)
+ (beginning-of-line 0)))
+ (setq beg (point)))
+ (set-mark end)
+ (goto-char beg)
+ (TeX-activate-region)))
+
+
+ (defun Texinfo-mark-section (&optional to-be-marked)
+ "Mark current section, with inclusion of any containing to-be-marked,
+ where current section is started by any of the structuring
+ commands matched by regexp in constant
+ `Texinfo-structuring-command-re'.
+
+ If optional argument TO-BE-MARKED is set to 1 or is a non nil empty
+ argument, then mark current node.
+
+ If optional argument TO-BE-MARKED is set to 2 or to `-', then
+ mark current section, with exclusion of any subsections."
+ (interactive "P")
+ (let (beg end is-beg-section is-end-section)
+ (cond
+ ;; node
+ ((or (eq to-be-marked 1) (and (consp to-be-marked) (eq (car
to-be-marked) 4)))
+ (setq beg
+ (save-excursion
+ (end-of-line)
+ (re-search-backward "address@hidden>" nil t ))
+ end
+ (save-excursion
+ (beginning-of-line)
+ (when
+ (re-search-forward "address@hidden(?:node\\|bye\\)\\_>" nil t
)
+ (beginning-of-line)
+ (point)))))
+ ;; section with exclusion of any subsection
+ ((memq to-be-marked '(- 2))
+ (setq beg (save-excursion
+ (end-of-line)
+ (re-search-backward Texinfo-structuring-command-re nil t))
+ is-beg-section t
+ end
+ (save-excursion
+ (beginning-of-line)
+ (when
+ (re-search-forward (concat Texinfo-structuring-command-re
+ "\\|address@hidden>" ) nil t)
+ (save-match-data
+ (beginning-of-line)
+ (point))))
+ is-end-section (match-string 1)))
+ ;;
+ (t
+ (let (section-command-level)
+ (setq beg
+ (save-excursion
+ (end-of-line)
+ (re-search-backward Texinfo-structuring-command-re nil t)))
+ (when beg
+ (setq is-beg-section t
+ section-command-level
+ (cdr (assoc (match-string 1)
Texinfo-structuring-command-levels-alist))
+ end
+ (save-excursion
+ (beginning-of-line)
+ (while
+ (and (re-search-forward (concat
Texinfo-structuring-command-re
+ "\\|address@hidden>" )
nil t)
+ (or
+ (null (setq is-end-section (match-string 1)))
+ (> (cdr (assoc is-end-section
Texinfo-structuring-command-levels-alist))
+ section-command-level))))
+ (when (match-string 0)
+ (beginning-of-line)
+ (point)))))))); (cond ...)
+ (when (and beg end)
+ ;; now take also enclosing node of beg and end
+ (dolist
+ (boundary '(beg end))
+ (when (symbol-value (intern (concat "is-" (symbol-name boundary)
"-section")))
+ (save-excursion
+ (goto-char (symbol-value boundary))
+ (while
+ (and
+ (null (bobp))
+ (progn
+ (beginning-of-line 0)
+ (looking-at "^\\s-*\\($\\|@\\(c\\|comment\\)\\_>\\)"))))
+ (when (looking-at "address@hidden>")
+ (set boundary (point))))))
+
+ (set-mark end)
+ (goto-char beg)
+ (TeX-activate-region) )))
+
(defun Texinfo-insert-node ()
"Insert a Texinfo node in the current buffer.
That means, insert the string address@hidden' and prompt for current,
***************
*** 231,236 ****
--- 367,374 ----
;; Simulating LaTeX-mode
(define-key map "\C-c\C-e" 'Texinfo-environment)
+ (define-key map "\C-c." 'Texinfo-mark-environment)
+ (define-key map "\C-c*" 'Texinfo-mark-section)
(define-key map "\C-c\n" 'address@hidden)
(or (key-binding "\e\r")
(define-key map "\e\r" 'address@hidden)) ;*** Alias
- [AUCTeX-devel] Re: Contribution to AUCTeX,
Vincent Belaïche <=