[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, 04 Jul 2010 23:55:37 +0200 |
[...]
>
> > 2010-06-03 Vincent Belaïche <address@hidden>
>
> It would be good if we'd only use one email address for your ChangeLog
> entries. The last one got the Gmail address.
>
This is strange, my add-log-mailing-address variable is configured with
the sourceforge address, because I mainly use change logs for jPicEdt
which is on Sourceforge. Probably the last time I edited some changelog
by hand, without using `C-x 4 a'.
OK, I promise: all my future contributions will use the same address,
the sourceforge one. Do you really mind if it remains
vincentb1(arobase)users.sourceforge.net.
> > + (defconst Texinfo-structuring-command-re
> > + (concat "^\\s-*@"
> > + (funcall 'regexp-opt (mapcar 'car texinfo-section-list)
> > + 'word))
>
> `regexp-opt' only knows `words', not `word'.
Ooops, corrected.
> Also, is the performance
> really so bad that the regexp has to be computed here?
Actually I realized that the outline-regexp can be used instead, and
therefore that constant Texinfo-structuring-command-re is not needed
anby longer as such.
I however declared Texinfo-structuring-command-re as a defvar to avoid
memory duplication (ie when there are several Texinfo buffer the same
string will be used in memory).
I also kept the regexp-opt, this is not really a question of execution
speed, I don't there there is any significant difference in speed, but a
regexp-opt use 245 byte memory while a mapconcat uses 296 bytes. Saving
memory is good because it affects all the system positively, and not
only section/node marking.
> In latex.el this
> is done one the fly which has the advantage that you don't have to reset
> the "variable" when you change `texinfo-section-list'.
>
Is that possible that texinfo-section-list be changed ?! that would mean
that the texinfo specification is changed. OK, I wrote the code in a way
there texinfo-section-list may have different values in different
buffers, Texinfo-structuring-command-re will just capture the one for
the 1st texinfo buffer edited.
> > + (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'.
>
> This docstring is not checkdoc-compliant. It should probably also
> mention `texinfo-section-list' instead of
> `Texinfo-structuring-command-re'.
>
Corrected. I ran checkdoc, and it is now OK.
> > + 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."
>
> Hm, that interface seems a bit awkard. I'm not sure it is very lispy to
> use numeric values with the prefix argument like that. The behavior
> also differs from `LaTeX-mark-section'. Perhaps there should be two
> separate commands, one for nodes and one for sectioning?
>
Well, do you have any more concrete suggestion ?
> With respect to the rest of the code, there are a few lines which are
> longer than 80 characters and should be shortened.
>
OK, I activated whitespace-mode and it is now OK, I also removed a
number of line tailing spaces.
> > + (define-key map "\C-c." 'Texinfo-mark-environment)
> > + (define-key map "\C-c*" 'Texinfo-mark-section)
>
> Those bindings are already marked as being dubious in latex.el because
> the Emacs key binding conventions do not really encourage to use them.
> So perhaps we should not introduce them in Texinfo mode as well.
>
> I'm not sure if there are better alternatives. Lisp mode, for example,
> has `C-M-h' for `mark-defun'. (Does anybody know where this `h'
> mnemonic stems from?) But then we are still one binding short.
>
In suspect that `h' is used because `C-x h' is already used to mark
whole buffer, abd that the `h' of `C-x h' comes from the pronounciation
of `whole', and this that `w' would be confusing as it makes to much
think of `window'. Well, I am speculating.
Well we could use the same binding C-M-SPC or C-M-@ used by mark-sexp to
mark environment, and C-M-h (used for defun) in order to mark sections.
If everybody agrees, I will do that in the next update.
Please find attached this update.
> --
> Ralf
Vincent.
*** c:/Programme/GNU/installation/auctex-install/auctex/tex-info.el Sun Jun
13 04:54:51 2010
--- tex-info.el Sun Jul 4 21:53:47 2010
***************
*** 49,61 ****
("ifxml") ("ignore") ("itemize") ("lisp") ("macro") ("menu")
("multitable") ("quotation") ("smalldisplay") ("smallexample")
("smallformat") ("smalllisp") ("table") ("tex") ("titlepage")
! ("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.")
--- 49,67 ----
("ifxml") ("ignore") ("itemize") ("lisp") ("macro") ("menu")
("multitable") ("quotation") ("smalldisplay") ("smallexample")
("smallformat") ("smalllisp") ("table") ("tex") ("titlepage")
! ("verbatim") ("vtable"))
"Alist of Texinfo environments.")
+ (defvar Texinfo-structuring-command-re nil
+ "Placeholder for regexp to match structuring commands.
+ This is done in order not to duplicate variable `outline-regexp'
+ memory footprint when several Texinfo buffers are edited.")
+
+
(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.")
***************
*** 132,138 ****
(if (= level 0)
(goto-char (match-end 0))
(error "Can't locate end of current environment")))))
!
(defun Texinfo-find-env-start ()
"Move point to the start of the current environment."
(interactive)
--- 138,144 ----
(if (= level 0)
(goto-char (match-end 0))
(error "Can't locate end of current environment")))))
!
(defun Texinfo-find-env-start ()
"Move point to the start of the current environment."
(interactive)
***************
*** 160,165 ****
--- 166,296 ----
(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 node.
+
+ The current section is detected as starting by any of the
+ structuring commands matched by regexp in variable
+ `outline-regexp' which in turn is a regexp matching any element
+ of variable `texinfo-section-list'.
+
+ 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 (concat "^\\s-*" outline-regexp) nil t))
+ is-beg-section t
+ end
+ (save-excursion
+ (beginning-of-line)
+ (when
+ (re-search-forward (concat "^\\s-*" outline-regexp
+ "\\|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 (concat "^\\s-*" outline-regexp) nil t)))
+ (when beg
+ (setq is-beg-section t
+ section-command-level
+ (cadr (assoc (match-string 1) texinfo-section-list))
+ end
+ (save-excursion
+ (beginning-of-line)
+ (while
+ (and (re-search-forward (concat "^\\s-*" outline-regexp
+ "\\|address@hidden>" )
+ nil t)
+ (or
+ (null (setq is-end-section (match-string 1)))
+ (> (cadr (assoc is-end-section
+ texinfo-section-list))
+ 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 ****
--- 362,369 ----
;; 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
***************
*** 318,324 ****
(?C "@cite{" "}")
(?\C-d "" "" t))
"Font commands used in Texinfo mode. See `TeX-font-list'.")
!
;;; Mode:
;;;###autoload
--- 451,457 ----
(?C "@cite{" "}")
(?\C-d "" "" t))
"Font commands used in Texinfo mode. See `TeX-font-list'.")
!
;;; Mode:
;;;###autoload
***************
*** 342,351 ****
(use-local-map Texinfo-mode-map)
(set-syntax-table texinfo-mode-syntax-table)
(make-local-variable 'page-delimiter)
! (setq page-delimiter
! (concat
! "address@hidden [ \t]*[Tt]op\\|address@hidden("
! texinfo-chapter-level-regexp
"\\)"))
(make-local-variable 'require-final-newline)
(setq require-final-newline t)
--- 475,484 ----
(use-local-map Texinfo-mode-map)
(set-syntax-table texinfo-mode-syntax-table)
(make-local-variable 'page-delimiter)
! (setq page-delimiter
! (concat
! "address@hidden [ \t]*[Tt]op\\|address@hidden("
! texinfo-chapter-level-regexp
"\\)"))
(make-local-variable 'require-final-newline)
(setq require-final-newline t)
***************
*** 383,396 ****
(if (not (boundp 'texinfo-section-list))
;; This was included in 19.31.
()
! (make-local-variable 'outline-regexp)
! (setq outline-regexp
! (concat "@\\("
! (mapconcat 'car texinfo-section-list "\\>\\|")
! "\\>\\)"))
(make-local-variable 'outline-level)
(setq outline-level 'texinfo-outline-level))
!
;; Mostly AUCTeX stuff
(easy-menu-add Texinfo-mode-menu Texinfo-mode-map)
(easy-menu-add Texinfo-command-menu Texinfo-mode-map)
--- 516,535 ----
(if (not (boundp 'texinfo-section-list))
;; This was included in 19.31.
()
! (set (make-local-variable 'outline-regexp)
! (let ((re (concat "@"
! (funcall 'regexp-opt
! (mapcar 'car texinfo-section-list)
! 'words))))
! (cond
! ((null Texinfo-structuring-command-re)
! (setq Texinfo-structuring-command-re re))
! ((string= Texinfo-structuring-command-re re)
! Texinfo-structuring-command-re)
! (t re))))
(make-local-variable 'outline-level)
(setq outline-level 'texinfo-outline-level))
!
;; Mostly AUCTeX stuff
(easy-menu-add Texinfo-mode-menu Texinfo-mode-map)
(easy-menu-add Texinfo-command-menu Texinfo-mode-map)
***************
*** 409,415 ****
(setq TeX-command-default "TeX")
(setq TeX-header-end "%*end")
(setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
!
(make-local-variable 'TeX-complete-list)
(setq TeX-complete-list
(list (list "@\\([a-zA-Z]*\\)" 1 'TeX-symbol-list nil)
--- 548,554 ----
(setq TeX-command-default "TeX")
(setq TeX-header-end "%*end")
(setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
!
(make-local-variable 'TeX-complete-list)
(setq TeX-complete-list
(list (list "@\\([a-zA-Z]*\\)" 1 'TeX-symbol-list nil)
***************
*** 419,425 ****
(setq TeX-font-list Texinfo-font-list)
(make-local-variable 'TeX-font-replace-function)
(setq TeX-font-replace-function 'TeX-font-replace-macro)
!
(add-hook 'find-file-hooks (lambda ()
(unless (file-exists-p (buffer-file-name))
(TeX-master-file nil nil t))) nil t)
--- 558,564 ----
(setq TeX-font-list Texinfo-font-list)
(make-local-variable 'TeX-font-replace-function)
(setq TeX-font-replace-function 'TeX-font-replace-macro)
!
(add-hook 'find-file-hooks (lambda ()
(unless (file-exists-p (buffer-file-name))
(TeX-master-file nil nil t))) nil t)
***************
*** 548,554 ****
'("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount"))
'("w" "Text")
'("xref" "Node name"))
!
(TeX-run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook)
(TeX-set-mode-name))
--- 687,693 ----
'("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount"))
'("w" "Text")
'("xref" "Node name"))
!
(TeX-run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook)
(TeX-set-mode-name))
***************
*** 568,574 ****
i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
:type '(repeat regexp)
:group 'TeX-command)
!
(provide 'tex-info)
!
;;; tex-info.el ends here
--- 707,713 ----
i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
:type '(repeat regexp)
:group 'TeX-command)
!
(provide 'tex-info)
!
;;; tex-info.el ends here
2010-06-03 Vincent Belaïche <address@hidden>
* tex-info.el (Texinfo-mark-section): Creation of function
(Texinfo-mark-environment): Creation of function
(texinfo-environment-regexp): optimize by use of regexp-opt
- [AUCTeX-devel] Re: Contribution to AUCTeX,
Vincent Belaïche <=