changeset 61431:bf74e258742e

(vhdl-mode-map-init): Don't override default TAB binding so tab-always-indent is obeyed. (vhdl-minibuffer-local-map): Move initialization into declaration. (vhdl-mode-abbrev-table-init): Mark the abbrevs as `system'. (vhdl-run-when-idle, vhdl-create-mode-menu, vhdl-character-to-event) (vhdl-hooked-abbrev): Avoid test for XEmacs. (vhdl-current-line): Use line-beginning-position. (vhdl-doc-variable, vhdl-doc-mode): Call help-setup-xref before with-output-to-temp-buffer, so the current position can be recorded.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 10 Apr 2005 18:15:43 +0000
parents 3c2020e9075f
children 7279141eb80e
files lisp/ChangeLog lisp/progmodes/vhdl-mode.el
diffstat 2 files changed, 165 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Apr 10 17:02:44 2005 +0000
+++ b/lisp/ChangeLog	Sun Apr 10 18:15:43 2005 +0000
@@ -1,13 +1,25 @@
+2005-04-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/vhdl-mode.el (vhdl-mode-map-init): Don't override default
+	TAB binding so tab-always-indent is obeyed.
+	(vhdl-minibuffer-local-map): Move initialization into declaration.
+	(vhdl-mode-abbrev-table-init): Mark the abbrevs as `system'.
+	(vhdl-run-when-idle, vhdl-create-mode-menu, vhdl-character-to-event)
+	(vhdl-hooked-abbrev): Avoid test for XEmacs.
+	(vhdl-current-line): Use line-beginning-position.
+	(vhdl-doc-variable, vhdl-doc-mode): Call help-setup-xref before
+	with-output-to-temp-buffer, so the current position can be recorded.
+
 2005-04-10  Masatake YAMATO  <jet@gyve.org>
 
-	* progmodes/compile.el (compilation-error-regexp-alist-alist): Add
-	regexp for gcov.
+	* progmodes/compile.el (compilation-error-regexp-alist-alist):
+	Add regexp for gcov.
 
 2005-04-06  Katsumi Yamaoka  <yamaoka@jpl.org>
 
-	* calendar/time-date.el (time-to-seconds): Don't use the #xhhhh
+	* calendar/time-date.el (time-to-seconds, seconds-to-time)
+	(days-to-time, time-subtract, time-add): Don't use the #xhhhh
 	syntax which Emacs 20 doesn't support.
-	(seconds-to-time, days-to-time, time-subtract, time-add): Ditto.
 
 2005-04-09  Stefan Monnier  <monnier@iro.umontreal.ca>
 
--- a/lisp/progmodes/vhdl-mode.el	Sun Apr 10 17:02:44 2005 +0000
+++ b/lisp/progmodes/vhdl-mode.el	Sun Apr 10 18:15:43 2005 +0000
@@ -2039,7 +2039,7 @@
 
 (defun vhdl-run-when-idle (secs repeat function)
   "Wait until idle, then run FUNCTION."
-  (if vhdl-xemacs
+  (if (fboundp 'start-itimer)
       (start-itimer "vhdl-mode" function secs repeat t)
 ;    (run-with-idle-timer secs repeat function)))
     ;; explicitely activate timer (necessary when Emacs is already idle)
@@ -2679,7 +2679,9 @@
   (define-key vhdl-mode-map " "            'vhdl-electric-space)
   (if vhdl-intelligent-tab
       (define-key vhdl-mode-map "\t"       'vhdl-electric-tab)
-    (define-key vhdl-mode-map "\t"         'indent-according-to-mode))
+    ;; The default binding of TAB already calls `indent-according-to-mode'.
+    ;; (define-key vhdl-mode-map "\t"         'indent-according-to-mode)
+    )
   (define-key vhdl-mode-map "\r"           'vhdl-electric-return)
   (define-key vhdl-mode-map "-"            'vhdl-electric-dash)
   (define-key vhdl-mode-map "["            'vhdl-electric-open-bracket)
@@ -2696,12 +2698,14 @@
 
 ;; define special minibuffer keymap for enabling word completion in minibuffer
 ;; (useful in template generator prompts)
-(defvar vhdl-minibuffer-local-map (copy-keymap minibuffer-local-map)
+(defvar vhdl-minibuffer-local-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map minibuffer-local-map)
+    (when vhdl-word-completion-in-minibuffer
+      (define-key map "\t" 'vhdl-minibuffer-tab))
+    map)
   "Keymap for minibuffer used in VHDL Mode.")
 
-(when vhdl-word-completion-in-minibuffer
-  (define-key vhdl-minibuffer-local-map "\t" 'vhdl-minibuffer-tab))
-
 ;; set up electric character functions to work with
 ;; `delete-selection-mode' (Emacs) and `pending-delete-mode' (XEmacs)
 (mapcar
@@ -2792,134 +2796,134 @@
      (when (memq 'vhdl vhdl-electric-keywords)
        ;; VHDL'93 keywords
        '(
-	 ("--"            "" vhdl-template-display-comment-hook 0)
-	 ("abs"           "" vhdl-template-default-hook 0)
-	 ("access"        "" vhdl-template-default-hook 0)
-	 ("after"         "" vhdl-template-default-hook 0)
-	 ("alias"         "" vhdl-template-alias-hook 0)
-	 ("all"           "" vhdl-template-default-hook 0)
-	 ("and"           "" vhdl-template-default-hook 0)
-	 ("arch"          "" vhdl-template-architecture-hook 0)
-	 ("architecture"  "" vhdl-template-architecture-hook 0)
-	 ("array"         "" vhdl-template-default-hook 0)
-	 ("assert"        "" vhdl-template-assert-hook 0)
-	 ("attr"          "" vhdl-template-attribute-hook 0)
-	 ("attribute"     "" vhdl-template-attribute-hook 0)
-	 ("begin"         "" vhdl-template-default-indent-hook 0)
-	 ("block"         "" vhdl-template-block-hook 0)
-	 ("body"          "" vhdl-template-default-hook 0)
-	 ("buffer"        "" vhdl-template-default-hook 0)
-	 ("bus"           "" vhdl-template-default-hook 0)
-	 ("case"          "" vhdl-template-case-hook 0)
-	 ("comp"          "" vhdl-template-component-hook 0)
-	 ("component"     "" vhdl-template-component-hook 0)
-	 ("cond"          "" vhdl-template-conditional-signal-asst-hook 0)
-	 ("conditional"   "" vhdl-template-conditional-signal-asst-hook 0)
-	 ("conf"          "" vhdl-template-configuration-hook 0)
-	 ("configuration" "" vhdl-template-configuration-hook 0)
-	 ("cons"          "" vhdl-template-constant-hook 0)
-	 ("constant"      "" vhdl-template-constant-hook 0)
-	 ("disconnect"    "" vhdl-template-disconnect-hook 0)
-	 ("downto"        "" vhdl-template-default-hook 0)
-	 ("else"          "" vhdl-template-else-hook 0)
-	 ("elseif"        "" vhdl-template-elsif-hook 0)
-	 ("elsif"         "" vhdl-template-elsif-hook 0)
-	 ("end"           "" vhdl-template-default-indent-hook 0)
-	 ("entity"        "" vhdl-template-entity-hook 0)
-	 ("exit"          "" vhdl-template-exit-hook 0)
-	 ("file"          "" vhdl-template-file-hook 0)
-	 ("for"           "" vhdl-template-for-hook 0)
-	 ("func"          "" vhdl-template-function-hook 0)
-	 ("function"      "" vhdl-template-function-hook 0)
-	 ("generic"       "" vhdl-template-generic-hook 0)
-	 ("group"         "" vhdl-template-group-hook 0)
-	 ("guarded"       "" vhdl-template-default-hook 0)
-	 ("if"            "" vhdl-template-if-hook 0)
-	 ("impure"        "" vhdl-template-default-hook 0)
-	 ("in"            "" vhdl-template-default-hook 0)
-	 ("inertial"      "" vhdl-template-default-hook 0)
-	 ("inout"         "" vhdl-template-default-hook 0)
-	 ("inst"          "" vhdl-template-instance-hook 0)
-	 ("instance"      "" vhdl-template-instance-hook 0)
-	 ("is"            "" vhdl-template-default-hook 0)
-	 ("label"         "" vhdl-template-default-hook 0)
-	 ("library"       "" vhdl-template-library-hook 0)
-	 ("linkage"       "" vhdl-template-default-hook 0)
-	 ("literal"       "" vhdl-template-default-hook 0)
-	 ("loop"          "" vhdl-template-bare-loop-hook 0)
-	 ("map"           "" vhdl-template-map-hook 0)
-	 ("mod"           "" vhdl-template-default-hook 0)
-	 ("nand"          "" vhdl-template-default-hook 0)
-	 ("new"           "" vhdl-template-default-hook 0)
-	 ("next"          "" vhdl-template-next-hook 0)
-	 ("nor"           "" vhdl-template-default-hook 0)
-	 ("not"           "" vhdl-template-default-hook 0)
-	 ("null"          "" vhdl-template-default-hook 0)
-	 ("of"            "" vhdl-template-default-hook 0)
-	 ("on"            "" vhdl-template-default-hook 0)
-	 ("open"          "" vhdl-template-default-hook 0)
-	 ("or"            "" vhdl-template-default-hook 0)
-	 ("others"        "" vhdl-template-others-hook 0)
-	 ("out"           "" vhdl-template-default-hook 0)
-	 ("pack"          "" vhdl-template-package-hook 0)
-	 ("package"       "" vhdl-template-package-hook 0)
-	 ("port"          "" vhdl-template-port-hook 0)
-	 ("postponed"     "" vhdl-template-default-hook 0)
-	 ("procedure"     "" vhdl-template-procedure-hook 0)
-	 ("process"       "" vhdl-template-process-hook 0)
-	 ("pure"          "" vhdl-template-default-hook 0)
-	 ("range"         "" vhdl-template-default-hook 0)
-	 ("record"        "" vhdl-template-default-hook 0)
-	 ("register"      "" vhdl-template-default-hook 0)
-	 ("reject"        "" vhdl-template-default-hook 0)
-	 ("rem"           "" vhdl-template-default-hook 0)
-	 ("report"        "" vhdl-template-report-hook 0)
-	 ("return"        "" vhdl-template-return-hook 0)
-	 ("rol"           "" vhdl-template-default-hook 0)
-	 ("ror"           "" vhdl-template-default-hook 0)
-	 ("select"        "" vhdl-template-selected-signal-asst-hook 0)
-	 ("severity"      "" vhdl-template-default-hook 0)
-	 ("shared"        "" vhdl-template-default-hook 0)
-	 ("sig"           "" vhdl-template-signal-hook 0)
-	 ("signal"        "" vhdl-template-signal-hook 0)
-	 ("sla"           "" vhdl-template-default-hook 0)
-	 ("sll"           "" vhdl-template-default-hook 0)
-	 ("sra"           "" vhdl-template-default-hook 0)
-	 ("srl"           "" vhdl-template-default-hook 0)
-	 ("subtype"       "" vhdl-template-subtype-hook 0)
-	 ("then"          "" vhdl-template-default-hook 0)
-	 ("to"            "" vhdl-template-default-hook 0)
-	 ("transport"     "" vhdl-template-default-hook 0)
-	 ("type"          "" vhdl-template-type-hook 0)
-	 ("unaffected"    "" vhdl-template-default-hook 0)
-	 ("units"         "" vhdl-template-default-hook 0)
-	 ("until"         "" vhdl-template-default-hook 0)
-	 ("use"           "" vhdl-template-use-hook 0)
-	 ("var"           "" vhdl-template-variable-hook 0)
-	 ("variable"      "" vhdl-template-variable-hook 0)
-	 ("wait"          "" vhdl-template-wait-hook 0)
-	 ("when"          "" vhdl-template-when-hook 0)
-	 ("while"         "" vhdl-template-while-loop-hook 0)
-	 ("with"          "" vhdl-template-with-hook 0)
-	 ("xnor"          "" vhdl-template-default-hook 0)
-	 ("xor"           "" vhdl-template-default-hook 0)
+	 ("--"            "" vhdl-template-display-comment-hook 0 t)
+	 ("abs"           "" vhdl-template-default-hook 0 t)
+	 ("access"        "" vhdl-template-default-hook 0 t)
+	 ("after"         "" vhdl-template-default-hook 0 t)
+	 ("alias"         "" vhdl-template-alias-hook 0 t)
+	 ("all"           "" vhdl-template-default-hook 0 t)
+	 ("and"           "" vhdl-template-default-hook 0 t)
+	 ("arch"          "" vhdl-template-architecture-hook 0 t)
+	 ("architecture"  "" vhdl-template-architecture-hook 0 t)
+	 ("array"         "" vhdl-template-default-hook 0 t)
+	 ("assert"        "" vhdl-template-assert-hook 0 t)
+	 ("attr"          "" vhdl-template-attribute-hook 0 t)
+	 ("attribute"     "" vhdl-template-attribute-hook 0 t)
+	 ("begin"         "" vhdl-template-default-indent-hook 0 t)
+	 ("block"         "" vhdl-template-block-hook 0 t)
+	 ("body"          "" vhdl-template-default-hook 0 t)
+	 ("buffer"        "" vhdl-template-default-hook 0 t)
+	 ("bus"           "" vhdl-template-default-hook 0 t)
+	 ("case"          "" vhdl-template-case-hook 0 t)
+	 ("comp"          "" vhdl-template-component-hook 0 t)
+	 ("component"     "" vhdl-template-component-hook 0 t)
+	 ("cond"          "" vhdl-template-conditional-signal-asst-hook 0 t)
+	 ("conditional"   "" vhdl-template-conditional-signal-asst-hook 0 t)
+	 ("conf"          "" vhdl-template-configuration-hook 0 t)
+	 ("configuration" "" vhdl-template-configuration-hook 0 t)
+	 ("cons"          "" vhdl-template-constant-hook 0 t)
+	 ("constant"      "" vhdl-template-constant-hook 0 t)
+	 ("disconnect"    "" vhdl-template-disconnect-hook 0 t)
+	 ("downto"        "" vhdl-template-default-hook 0 t)
+	 ("else"          "" vhdl-template-else-hook 0 t)
+	 ("elseif"        "" vhdl-template-elsif-hook 0 t)
+	 ("elsif"         "" vhdl-template-elsif-hook 0 t)
+	 ("end"           "" vhdl-template-default-indent-hook 0 t)
+	 ("entity"        "" vhdl-template-entity-hook 0 t)
+	 ("exit"          "" vhdl-template-exit-hook 0 t)
+	 ("file"          "" vhdl-template-file-hook 0 t)
+	 ("for"           "" vhdl-template-for-hook 0 t)
+	 ("func"          "" vhdl-template-function-hook 0 t)
+	 ("function"      "" vhdl-template-function-hook 0 t)
+	 ("generic"       "" vhdl-template-generic-hook 0 t)
+	 ("group"         "" vhdl-template-group-hook 0 t)
+	 ("guarded"       "" vhdl-template-default-hook 0 t)
+	 ("if"            "" vhdl-template-if-hook 0 t)
+	 ("impure"        "" vhdl-template-default-hook 0 t)
+	 ("in"            "" vhdl-template-default-hook 0 t)
+	 ("inertial"      "" vhdl-template-default-hook 0 t)
+	 ("inout"         "" vhdl-template-default-hook 0 t)
+	 ("inst"          "" vhdl-template-instance-hook 0 t)
+	 ("instance"      "" vhdl-template-instance-hook 0 t)
+	 ("is"            "" vhdl-template-default-hook 0 t)
+	 ("label"         "" vhdl-template-default-hook 0 t)
+	 ("library"       "" vhdl-template-library-hook 0 t)
+	 ("linkage"       "" vhdl-template-default-hook 0 t)
+	 ("literal"       "" vhdl-template-default-hook 0 t)
+	 ("loop"          "" vhdl-template-bare-loop-hook 0 t)
+	 ("map"           "" vhdl-template-map-hook 0 t)
+	 ("mod"           "" vhdl-template-default-hook 0 t)
+	 ("nand"          "" vhdl-template-default-hook 0 t)
+	 ("new"           "" vhdl-template-default-hook 0 t)
+	 ("next"          "" vhdl-template-next-hook 0 t)
+	 ("nor"           "" vhdl-template-default-hook 0 t)
+	 ("not"           "" vhdl-template-default-hook 0 t)
+	 ("null"          "" vhdl-template-default-hook 0 t)
+	 ("of"            "" vhdl-template-default-hook 0 t)
+	 ("on"            "" vhdl-template-default-hook 0 t)
+	 ("open"          "" vhdl-template-default-hook 0 t)
+	 ("or"            "" vhdl-template-default-hook 0 t)
+	 ("others"        "" vhdl-template-others-hook 0 t)
+	 ("out"           "" vhdl-template-default-hook 0 t)
+	 ("pack"          "" vhdl-template-package-hook 0 t)
+	 ("package"       "" vhdl-template-package-hook 0 t)
+	 ("port"          "" vhdl-template-port-hook 0 t)
+	 ("postponed"     "" vhdl-template-default-hook 0 t)
+	 ("procedure"     "" vhdl-template-procedure-hook 0 t)
+	 ("process"       "" vhdl-template-process-hook 0 t)
+	 ("pure"          "" vhdl-template-default-hook 0 t)
+	 ("range"         "" vhdl-template-default-hook 0 t)
+	 ("record"        "" vhdl-template-default-hook 0 t)
+	 ("register"      "" vhdl-template-default-hook 0 t)
+	 ("reject"        "" vhdl-template-default-hook 0 t)
+	 ("rem"           "" vhdl-template-default-hook 0 t)
+	 ("report"        "" vhdl-template-report-hook 0 t)
+	 ("return"        "" vhdl-template-return-hook 0 t)
+	 ("rol"           "" vhdl-template-default-hook 0 t)
+	 ("ror"           "" vhdl-template-default-hook 0 t)
+	 ("select"        "" vhdl-template-selected-signal-asst-hook 0 t)
+	 ("severity"      "" vhdl-template-default-hook 0 t)
+	 ("shared"        "" vhdl-template-default-hook 0 t)
+	 ("sig"           "" vhdl-template-signal-hook 0 t)
+	 ("signal"        "" vhdl-template-signal-hook 0 t)
+	 ("sla"           "" vhdl-template-default-hook 0 t)
+	 ("sll"           "" vhdl-template-default-hook 0 t)
+	 ("sra"           "" vhdl-template-default-hook 0 t)
+	 ("srl"           "" vhdl-template-default-hook 0 t)
+	 ("subtype"       "" vhdl-template-subtype-hook 0 t)
+	 ("then"          "" vhdl-template-default-hook 0 t)
+	 ("to"            "" vhdl-template-default-hook 0 t)
+	 ("transport"     "" vhdl-template-default-hook 0 t)
+	 ("type"          "" vhdl-template-type-hook 0 t)
+	 ("unaffected"    "" vhdl-template-default-hook 0 t)
+	 ("units"         "" vhdl-template-default-hook 0 t)
+	 ("until"         "" vhdl-template-default-hook 0 t)
+	 ("use"           "" vhdl-template-use-hook 0 t)
+	 ("var"           "" vhdl-template-variable-hook 0 t)
+	 ("variable"      "" vhdl-template-variable-hook 0 t)
+	 ("wait"          "" vhdl-template-wait-hook 0 t)
+	 ("when"          "" vhdl-template-when-hook 0 t)
+	 ("while"         "" vhdl-template-while-loop-hook 0 t)
+	 ("with"          "" vhdl-template-with-hook 0 t)
+	 ("xnor"          "" vhdl-template-default-hook 0 t)
+	 ("xor"           "" vhdl-template-default-hook 0 t)
 	 ))
      ;; VHDL-AMS keywords
      (when (and (memq 'vhdl vhdl-electric-keywords) (vhdl-standard-p 'ams))
        '(
-	 ("across"     "" vhdl-template-default-hook 0)
-	 ("break"      "" vhdl-template-break-hook 0)
-	 ("limit"      "" vhdl-template-limit-hook 0)
-	 ("nature"     "" vhdl-template-nature-hook 0)
-	 ("noise"      "" vhdl-template-default-hook 0)
-	 ("procedural" "" vhdl-template-procedural-hook 0)
-	 ("quantity"   "" vhdl-template-quantity-hook 0)
-	 ("reference"  "" vhdl-template-default-hook 0)
-	 ("spectrum"   "" vhdl-template-default-hook 0)
-	 ("subnature"  "" vhdl-template-subnature-hook 0)
-	 ("terminal"   "" vhdl-template-terminal-hook 0)
-	 ("through"    "" vhdl-template-default-hook 0)
-	 ("tolerance"  "" vhdl-template-default-hook 0)
+	 ("across"     "" vhdl-template-default-hook 0 t)
+	 ("break"      "" vhdl-template-break-hook 0 t)
+	 ("limit"      "" vhdl-template-limit-hook 0 t)
+	 ("nature"     "" vhdl-template-nature-hook 0 t)
+	 ("noise"      "" vhdl-template-default-hook 0 t)
+	 ("procedural" "" vhdl-template-procedural-hook 0 t)
+	 ("quantity"   "" vhdl-template-quantity-hook 0 t)
+	 ("reference"  "" vhdl-template-default-hook 0 t)
+	 ("spectrum"   "" vhdl-template-default-hook 0 t)
+	 ("subnature"  "" vhdl-template-subnature-hook 0 t)
+	 ("terminal"   "" vhdl-template-terminal-hook 0 t)
+	 ("through"    "" vhdl-template-default-hook 0 t)
+	 ("tolerance"  "" vhdl-template-default-hook 0 t)
 	 ))
      ;; user model keywords
      (when (memq 'user vhdl-electric-keywords)
@@ -2931,7 +2935,7 @@
 	     (setq abbrev-list
 		   (cons (list keyword ""
 			       (vhdl-function-name
-				"vhdl-model" (nth 0 (car alist)) "hook") 0)
+				"vhdl-model" (nth 0 (car alist)) "hook") 0 t)
 			 abbrev-list)))
 	   (setq alist (cdr alist)))
 	 abbrev-list)))))
@@ -3746,7 +3750,8 @@
      ("Highlight"
       ["Highlighting On/Off..."
        (customize-option
-	(if vhdl-xemacs 'font-lock-auto-fontify 'global-font-lock-mode)) t]
+	(if (fboundp 'global-font-lock-mode)
+	    'global-font-lock-mode 'font-lock-auto-fontify)) t]
       ["Highlight Keywords"
        (progn (customize-set-variable 'vhdl-highlight-keywords
 				      (not vhdl-highlight-keywords))
@@ -7854,7 +7859,7 @@
 ;; correct different behavior of function `unread-command-events' in XEmacs
 (defun vhdl-character-to-event (arg))
 (defalias 'vhdl-character-to-event
-  (if vhdl-xemacs 'character-to-event 'identity))
+  (if (fboundp 'character-to-event) 'character-to-event 'identity))
 
 (defun vhdl-work-library ()
   "Return the working library name of the current project or \"work\" if no
@@ -10399,7 +10404,7 @@
 	  (when (stringp caught) (message caught)))
 	(when (= invoke-char ?-) (setq abbrev-start-location (point)))
 	;; delete CR which is still in event queue
-	(if vhdl-xemacs
+	(if (fboundp 'enqueue-eval-event)
 	    (enqueue-eval-event 'delete-char -1)
 	  (setq unread-command-events	; push back a delete char
 		(list (vhdl-character-to-event ?\177))))))))
@@ -11923,9 +11928,7 @@
   "Return the line number of the line containing point."
   (save-restriction
     (widen)
-    (save-excursion
-      (beginning-of-line)
-      (1+ (count-lines 1 (point))))))
+    (1+ (count-lines (point-min) (line-beginning-position)))))
 
 (defun vhdl-line-kill-entire (&optional arg)
   "Delete entire line."
@@ -16559,26 +16562,24 @@
 (defun vhdl-doc-variable (variable)
   "Display VARIABLE's documentation in *Help* buffer."
   (interactive)
-  (with-output-to-temp-buffer "*Help*"
+  (unless vhdl-xemacs
+    (help-setup-xref (list #'vhdl-doc-variable variable) (interactive-p)))
+  (with-output-to-temp-buffer (if (fboundp 'help-buffer) (help-buffer) "*Help*")
     (princ (documentation-property variable 'variable-documentation))
-    (unless vhdl-xemacs
-      (help-setup-xref (list #'vhdl-doc-variable variable) (interactive-p)))
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (help-mode))
     (print-help-return-message)))
 
 (defun vhdl-doc-mode ()
   "Display VHDL Mode documentation in *Help* buffer."
   (interactive)
-  (with-output-to-temp-buffer "*Help*"
+  (unless vhdl-xemacs
+    (help-setup-xref (list #'vhdl-doc-mode) (interactive-p)))
+  (with-output-to-temp-buffer (if (fboundp 'help-buffer) (help-buffer) "*Help*")
     (princ mode-name)
     (princ " mode:\n")
     (princ (documentation 'vhdl-mode))
-    (unless vhdl-xemacs
-      (help-setup-xref (list #'vhdl-doc-mode) (interactive-p)))
-    (save-excursion
-      (set-buffer standard-output)
+    (with-current-buffer standard-output
       (help-mode))
     (print-help-return-message)))
 
@@ -16587,5 +16588,5 @@
 
 (provide 'vhdl-mode)
 
-;;; arch-tag: 780d7073-9b5d-4c6c-b0d8-26b28783aba3
+;; arch-tag: 780d7073-9b5d-4c6c-b0d8-26b28783aba3
 ;;; vhdl-mode.el ends here