Function: texinfo-start-menu-description

texinfo-start-menu-description is an autoloaded, interactive and byte-compiled function defined in texnfo-upd.el.gz.

Signature

(texinfo-start-menu-description)

Documentation

In this menu entry, insert the node's section title as a description.

Position point at beginning of description ready for editing. Do not insert a title if the line contains an existing description.

You will need to edit the inserted text since a useful description complements the node name rather than repeats it as a title does.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/texnfo-upd.el.gz
;;; Starting menu descriptions by inserting titles

;;;###autoload
(defun texinfo-start-menu-description ()
  "In this menu entry, insert the node's section title as a description.
Position point at beginning of description ready for editing.
Do not insert a title if the line contains an existing description.

You will need to edit the inserted text since a useful description
complements the node name rather than repeats it as a title does."

  (interactive)
  (let (beginning node-name title) ;; end
    (save-excursion
      (beginning-of-line)
      (if (search-forward "* " (line-end-position) t)
	  (progn (skip-chars-forward " \t")
		 (setq beginning (point)))
	(error "This is not a line in a menu"))

      (cond
       ;; "Double colon" entry line; menu entry and node name are the same,
       ((search-forward "::" (line-end-position) t)
	(if (looking-at "[ \t]*[^ \t\n]+")
	    (error "Descriptive text already exists"))
	(skip-chars-backward ": \t")
	(setq node-name (buffer-substring beginning (point))))

       ;; "Single colon" entry line; menu entry and node name are different.
       ((search-forward ":" (line-end-position) t)
	(skip-chars-forward " \t")
	(setq beginning (point))
	;; Menu entry line ends in a period, comma, or tab.
	(if (re-search-forward "[.,\t]" (line-beginning-position 2) t)
	    (progn
	      (if (looking-at "[ \t]*[^ \t\n]+")
		  (error "Descriptive text already exists"))
	      (skip-chars-backward "., \t")
	      (setq node-name (buffer-substring beginning (point))))
	  ;; Menu entry line ends in a return.
	  (re-search-forward ".*\n" (line-beginning-position 2) t)
	  (skip-chars-backward " \t\n")
	  (setq node-name (buffer-substring beginning (point)))
	  (if (= 0 (length node-name))
	      (error "No node name on this line")
	    (insert "."))))
       (t (error "No node name on this line")))
      ;; Search for node that matches node name, and copy the section title.
      (if (re-search-forward
	   (concat
	    "^@node[ \t]+"
	    (regexp-quote node-name)
	    ".*\n"			; match node line
	    "\\("
	    "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any
	    "\\|"                              ; or
	    "\\(^@ifinfo[ ]*\n\\)"             ; ifinfo line, if any
            "\\|"                              ; or
            "\\(^@ifnottex[ ]*\n\\)"           ; ifnottex line, if any
            "\\)?"                             ; end of expression
	    )
	   nil t)
          (setq title
		(buffer-substring
		 ;; skip over section type
		 (progn (forward-word-strictly 1)
			;; and over spaces
			(skip-chars-forward " \t")
			(point))
		 (progn (end-of-line)
			(skip-chars-backward " \t")
			(point))))
	(error "Cannot find node to match node name in menu entry")))
    ;; Return point to the menu and insert the title.
    (end-of-line)
    (delete-region
     (point)
     (save-excursion (skip-chars-backward " \t") (point)))
    (indent-to texinfo-column-for-description 2)
    (save-excursion (insert title))))