aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-12-10 09:10:08 -0500
committerStefan Monnier2010-12-10 09:10:08 -0500
commit61f91c047655dbdd2deafadd15a0b592c9457df5 (patch)
treed733356b31df9f2a24da9681f8803a7ad9d577fe
parent72a446736e19bd2caf81006f4e9711bd6c80de41 (diff)
downloademacs-61f91c047655dbdd2deafadd15a0b592c9457df5.tar.gz
emacs-61f91c047655dbdd2deafadd15a0b592c9457df5.zip
* lisp/textmodes/texinfo.el (texinfo-mode-map): Bind texinfo-insert-@end.
(texinfo-mode): Don't disable adaptive-fill-mode. (texinfo-insert-block): Adjust cursor placement for blocks with arg. (texinfo-insert-@end, texinfo-insert-braces, texinfo-insert-@code) (texinfo-insert-@dfn, texinfo-insert-@email, texinfo-insert-@emph) (texinfo-insert-@example, texinfo-insert-@file, texinfo-insert-@item) (texinfo-insert-@kbd, texinfo-insert-@node, texinfo-insert-@noindent) (texinfo-insert-@quotation, texinfo-insert-@samp) (texinfo-insert-@strong, texinfo-insert-@table, texinfo-insert-@var) (texinfo-insert-@uref): Use define-skeleton. (texinfo-insert-@-with-arg): Delete.
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/textmodes/texinfo.el161
2 files changed, 83 insertions, 96 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 97d78d8070c..11511851447 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,17 @@
12010-12-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * textmodes/texinfo.el (texinfo-mode-map): Bind texinfo-insert-@end.
4 (texinfo-mode): Don't disable adaptive-fill-mode.
5 (texinfo-insert-block): Adjust cursor placement for blocks with arg.
6 (texinfo-insert-@end, texinfo-insert-braces, texinfo-insert-@code)
7 (texinfo-insert-@dfn, texinfo-insert-@email, texinfo-insert-@emph)
8 (texinfo-insert-@example, texinfo-insert-@file, texinfo-insert-@item)
9 (texinfo-insert-@kbd, texinfo-insert-@node, texinfo-insert-@noindent)
10 (texinfo-insert-@quotation, texinfo-insert-@samp)
11 (texinfo-insert-@strong, texinfo-insert-@table, texinfo-insert-@var)
12 (texinfo-insert-@uref): Use define-skeleton.
13 (texinfo-insert-@-with-arg): Delete.
14
12010-12-10 Eli Zaretskii <eliz@gnu.org> 152010-12-10 Eli Zaretskii <eliz@gnu.org>
2 16
3 * arc-mode.el (archive-zip-extract): If w32-quote-process-args is 17 * arc-mode.el (archive-zip-extract): If w32-quote-process-args is
@@ -16,8 +30,8 @@
16 30
17 * menu-bar.el (menu-bar-frame-for-menubar, menu-bar-positive-p): 31 * menu-bar.el (menu-bar-frame-for-menubar, menu-bar-positive-p):
18 New functions. 32 New functions.
19 (menu-bar-showhide-menu) <menu-bar-mode, showhide-tool-bar>: Use 33 (menu-bar-showhide-menu) <menu-bar-mode, showhide-tool-bar>:
20 them instead of `nil' and `>', respectively. 34 Use them instead of `nil' and `>', respectively.
21 (menu-bar-showhide-tool-bar-menu): Use menu-bar-frame-for-menubar 35 (menu-bar-showhide-tool-bar-menu): Use menu-bar-frame-for-menubar
22 instead of `nil'. 36 instead of `nil'.
23 (toggle-menu-bar-mode-from-frame): Use menu-bar-frame-for-menubar 37 (toggle-menu-bar-mode-from-frame): Use menu-bar-frame-for-menubar
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index be23a439bf3..ea691ee8ee4 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -443,7 +443,9 @@ Subexpression 1 is what goes into the corresponding `@end' statement.")
443 (define-key map "\C-c\C-s" 'texinfo-show-structure) 443 (define-key map "\C-c\C-s" 'texinfo-show-structure)
444 444
445 (define-key map "\C-c}" 'up-list) 445 (define-key map "\C-c}" 'up-list)
446 ;; FIXME: This is often used for "close block" aka texinfo-insert-@end.
446 (define-key map "\C-c]" 'up-list) 447 (define-key map "\C-c]" 'up-list)
448 (define-key map "\C-c/" 'texinfo-insert-@end)
447 (define-key map "\C-c{" 'texinfo-insert-braces) 449 (define-key map "\C-c{" 'texinfo-insert-braces)
448 450
449 ;; bindings for inserting strings 451 ;; bindings for inserting strings
@@ -583,11 +585,8 @@ value of `texinfo-mode-hook'."
583 (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate)) 585 (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-separate))
584 (make-local-variable 'paragraph-start) 586 (make-local-variable 'paragraph-start)
585 (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start)) 587 (setq paragraph-start (concat "\b\\|@[a-zA-Z]*[ \n]\\|" paragraph-start))
586 (make-local-variable 'sentence-end-base) 588 (set (make-local-variable 'sentence-end-base)
587 (setq sentence-end-base
588 "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") 589 "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*")
589 (make-local-variable 'adaptive-fill-mode)
590 (setq adaptive-fill-mode nil)
591 (make-local-variable 'fill-column) 590 (make-local-variable 'fill-column)
592 (setq fill-column 70) 591 (setq fill-column 70)
593 (make-local-variable 'comment-start) 592 (make-local-variable 'comment-start)
@@ -646,7 +645,13 @@ Puts point on a blank line between them."
646 (completing-read (format "Block name [%s]: " texinfo-block-default) 645 (completing-read (format "Block name [%s]: " texinfo-block-default)
647 texinfo-environments 646 texinfo-environments
648 nil nil nil nil texinfo-block-default)) 647 nil nil nil nil texinfo-block-default))
649 \n "@" str \n _ \n "@end " str \n) 648 \n "@" str
649 ;; Blocks that take parameters: all the def* blocks take parameters,
650 ;; plus a few others.
651 (if (or (string-match "\\`def" str)
652 (member str '("table" "ftable" "vtable")))
653 '(nil " " -))
654 \n _ \n "@end " str \n)
650 655
651(defun texinfo-inside-macro-p (macro &optional bound) 656(defun texinfo-inside-macro-p (macro &optional bound)
652 "Non-nil if inside a macro matching the regexp MACRO." 657 "Non-nil if inside a macro matching the regexp MACRO."
@@ -717,163 +722,131 @@ With prefix argument or inside @code or @example, inserts a plain \"."
717 (not (looking-at "@end")))) 722 (not (looking-at "@end"))))
718 (texinfo-next-unmatched-end))) 723 (texinfo-next-unmatched-end)))
719 724
720(defun texinfo-insert-@end () 725(define-skeleton texinfo-insert-@end
721 "Insert the matching `@end' for the last Texinfo command that needs one." 726 "Insert the matching `@end' for the last Texinfo command that needs one."
722 (interactive)
723 (let ((string
724 (ignore-errors 727 (ignore-errors
725 (save-excursion 728 (save-excursion
729 (backward-word 1)
726 (texinfo-last-unended-begin) 730 (texinfo-last-unended-begin)
727 (match-string 1))))) 731 (or (match-string 1) '-)))
728 (insert "@end ") 732 \n "@end " str \n)
729 (if string (insert string "\n")))) 733
730 734(define-skeleton texinfo-insert-braces
731;; The following insert commands accept a prefix arg N, which is the
732;; number of words (actually s-exprs) that should be surrounded by
733;; braces. Thus you can first paste a variable name into a .texinfo
734;; buffer, then say C-u 1 C-c C-c v at the beginning of the just
735;; pasted variable name to put @var{...} *around* the variable name.
736;; Operate on previous word or words with negative arg.
737
738;; These commands use texinfo-insert-@-with-arg
739(defun texinfo-insert-@-with-arg (string &optional arg)
740 (if arg
741 (progn
742 (setq arg (prefix-numeric-value arg))
743 (if (< arg 0)
744 (progn
745 (skip-chars-backward " \t\n\r\f")
746 (save-excursion
747 (forward-sexp arg)
748 (insert "@" string "{"))
749 (insert "}"))
750 (skip-chars-forward " \t\n\r\f")
751 (insert "@" string "{")
752 (forward-sexp arg)
753 (insert "}")))
754 (insert "@" string "{}")
755 (backward-char)))
756
757(defun texinfo-insert-braces ()
758 "Make a pair of braces and be poised to type inside of them. 735 "Make a pair of braces and be poised to type inside of them.
759Use \\[up-list] to move forward out of the braces." 736Use \\[up-list] to move forward out of the braces."
760 (interactive) 737 nil
761 (insert "{}") 738 "{" _ "}")
762 (backward-char))
763 739
764(defun texinfo-insert-@code (&optional arg) 740(define-skeleton texinfo-insert-@code
765 "Insert a `@code{...}' command in a Texinfo buffer. 741 "Insert a `@code{...}' command in a Texinfo buffer.
766A numeric argument says how many words the braces should surround. 742A numeric argument says how many words the braces should surround.
767The default is not to surround any existing words with the braces." 743The default is not to surround any existing words with the braces."
768 (interactive "P") 744 nil
769 (texinfo-insert-@-with-arg "code" arg)) 745 "@code{" _ "}")
770 746
771(defun texinfo-insert-@dfn (&optional arg) 747(define-skeleton texinfo-insert-@dfn
772 "Insert a `@dfn{...}' command in a Texinfo buffer. 748 "Insert a `@dfn{...}' command in a Texinfo buffer.
773A numeric argument says how many words the braces should surround. 749A numeric argument says how many words the braces should surround.
774The default is not to surround any existing words with the braces." 750The default is not to surround any existing words with the braces."
775 (interactive "P") 751 nil
776 (texinfo-insert-@-with-arg "dfn" arg)) 752 "@dfn{" _ "}")
777 753
778(defun texinfo-insert-@email (&optional arg) 754(define-skeleton texinfo-insert-@email
779 "Insert a `@email{...}' command in a Texinfo buffer. 755 "Insert a `@email{...}' command in a Texinfo buffer.
780A numeric argument says how many words the braces should surround. 756A numeric argument says how many words the braces should surround.
781The default is not to surround any existing words with the braces." 757The default is not to surround any existing words with the braces."
782 (interactive "P") 758 nil
783 (texinfo-insert-@-with-arg "email" arg)) 759 "@email{" _ "}")
784 760
785(defun texinfo-insert-@emph (&optional arg) 761(define-skeleton texinfo-insert-@emph
786 "Insert a `@emph{...}' command in a Texinfo buffer. 762 "Insert a `@emph{...}' command in a Texinfo buffer.
787A numeric argument says how many words the braces should surround. 763A numeric argument says how many words the braces should surround.
788The default is not to surround any existing words with the braces." 764The default is not to surround any existing words with the braces."
789 (interactive "P") 765 nil
790 (texinfo-insert-@-with-arg "emph" arg)) 766 "@emph{" _ "}")
791 767
792(defun texinfo-insert-@example () 768(define-skeleton texinfo-insert-@example
793 "Insert the string `@example' in a Texinfo buffer." 769 "Insert the string `@example' in a Texinfo buffer."
794 (interactive) 770 nil
795 (insert "@example\n")) 771 \n "@example" \n)
796 772
797(defun texinfo-insert-@file (&optional arg) 773(define-skeleton texinfo-insert-@file
798 "Insert a `@file{...}' command in a Texinfo buffer. 774 "Insert a `@file{...}' command in a Texinfo buffer.
799A numeric argument says how many words the braces should surround. 775A numeric argument says how many words the braces should surround.
800The default is not to surround any existing words with the braces." 776The default is not to surround any existing words with the braces."
801 (interactive "P") 777 nil
802 (texinfo-insert-@-with-arg "file" arg)) 778 "@file{" _ "}")
803 779
804(defun texinfo-insert-@item () 780(define-skeleton texinfo-insert-@item
805 "Insert the string `@item' in a Texinfo buffer. 781 "Insert the string `@item' in a Texinfo buffer.
806If in a table defined by @table, follow said string with a space. 782If in a table defined by @table, follow said string with a space.
807Otherwise, follow with a newline." 783Otherwise, follow with a newline."
808 (interactive) 784 nil
809 (insert "@item" 785 \n "@item"
810 (if (equal (ignore-errors 786 (if (equal (ignore-errors
811 (save-excursion 787 (save-excursion
812 (texinfo-last-unended-begin) 788 (texinfo-last-unended-begin)
813 (match-string 1))) 789 (match-string 1)))
814 "table") 790 "table")
815 ?\s 791 " " '\n)
816 ?\n))) 792 _ \n)
817 793
818(defun texinfo-insert-@kbd (&optional arg) 794(define-skeleton texinfo-insert-@kbd
819 "Insert a `@kbd{...}' command in a Texinfo buffer. 795 "Insert a `@kbd{...}' command in a Texinfo buffer.
820A numeric argument says how many words the braces should surround. 796A numeric argument says how many words the braces should surround.
821The default is not to surround any existing words with the braces." 797The default is not to surround any existing words with the braces."
822 (interactive "P") 798 nil
823 (texinfo-insert-@-with-arg "kbd" arg)) 799 "@kbd{" _ "}")
824 800
825(defun texinfo-insert-@node () 801(define-skeleton texinfo-insert-@node
826 "Insert the string `@node' in a Texinfo buffer. 802 "Insert the string `@node' in a Texinfo buffer.
827Insert a comment on the following line indicating the order of 803Insert a comment on the following line indicating the order of
828arguments to @node. Insert a carriage return after the comment line. 804arguments to @node. Insert a carriage return after the comment line.
829Leave point after `@node'." 805Leave point after `@node'."
830 (interactive) 806 nil
831 (insert "@node \n@comment node-name, next, previous, up\n") 807 \n "@node " _ \n)
832 (forward-line -2)
833 (forward-char 6))
834 808
835(defun texinfo-insert-@noindent () 809(define-skeleton texinfo-insert-@noindent
836 "Insert the string `@noindent' in a Texinfo buffer." 810 "Insert the string `@noindent' in a Texinfo buffer."
837 (interactive) 811 nil
838 (insert "@noindent\n")) 812 \n "@noindent" \n)
839 813
840(defun texinfo-insert-@quotation () 814(define-skeleton texinfo-insert-@quotation
841 "Insert the string `@quotation' in a Texinfo buffer." 815 "Insert the string `@quotation' in a Texinfo buffer."
842 (interactive) 816 \n "@quotation" \n)
843 (insert "@quotation\n"))
844 817
845(defun texinfo-insert-@samp (&optional arg) 818(define-skeleton texinfo-insert-@samp
846 "Insert a `@samp{...}' command in a Texinfo buffer. 819 "Insert a `@samp{...}' command in a Texinfo buffer.
847A numeric argument says how many words the braces should surround. 820A numeric argument says how many words the braces should surround.
848The default is not to surround any existing words with the braces." 821The default is not to surround any existing words with the braces."
849 (interactive "P") 822 nil
850 (texinfo-insert-@-with-arg "samp" arg)) 823 "@samp{" _ "}")
851 824
852(defun texinfo-insert-@strong (&optional arg) 825(define-skeleton texinfo-insert-@strong
853 "Insert a `@strong{...}' command in a Texinfo buffer. 826 "Insert a `@strong{...}' command in a Texinfo buffer.
854A numeric argument says how many words the braces should surround. 827A numeric argument says how many words the braces should surround.
855The default is not to surround any existing words with the braces." 828The default is not to surround any existing words with the braces."
856 (interactive "P") 829 nil
857 (texinfo-insert-@-with-arg "strong" arg)) 830 "@strong{" _ "}")
858 831
859(defun texinfo-insert-@table () 832(define-skeleton texinfo-insert-@table
860 "Insert the string `@table' in a Texinfo buffer." 833 "Insert the string `@table' in a Texinfo buffer."
861 (interactive) 834 nil
862 (insert "@table ")) 835 \n "@table " _ \n)
863 836
864(defun texinfo-insert-@var (&optional arg) 837(define-skeleton texinfo-insert-@var
865 "Insert a `@var{}' command in a Texinfo buffer. 838 "Insert a `@var{}' command in a Texinfo buffer.
866A numeric argument says how many words the braces should surround. 839A numeric argument says how many words the braces should surround.
867The default is not to surround any existing words with the braces." 840The default is not to surround any existing words with the braces."
868 (interactive "P") 841 nil
869 (texinfo-insert-@-with-arg "var" arg)) 842 "@var{" _ "}")
870 843
871(defun texinfo-insert-@uref (&optional arg) 844(define-skeleton texinfo-insert-@uref
872 "Insert a `@uref{}' command in a Texinfo buffer. 845 "Insert a `@uref{}' command in a Texinfo buffer.
873A numeric argument says how many words the braces should surround. 846A numeric argument says how many words the braces should surround.
874The default is not to surround any existing words with the braces." 847The default is not to surround any existing words with the braces."
875 (interactive "P") 848 nil
876 (texinfo-insert-@-with-arg "uref" arg)) 849 "@uref{" _ "}")
877(defalias 'texinfo-insert-@url 'texinfo-insert-@uref) 850(defalias 'texinfo-insert-@url 'texinfo-insert-@uref)
878 851
879;;; Texinfo file structure 852;;; Texinfo file structure