Skip to content

Commit

Permalink
Define php-mode-map in a defvar, as is the recommended style.
Browse files Browse the repository at this point in the history
See Tips for Defining(elisp).

Signed-off-by: Eric James Michael Ritz <[email protected]>
  • Loading branch information
haxney authored and Eric James Michael Ritz committed Jan 28, 2013
1 parent 5080f30 commit 3699aca
Showing 1 changed file with 24 additions and 42 deletions.
66 changes: 24 additions & 42 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,30 @@ This is was done due to the problem reported here:
(delete-char (* (funcall count-func 'arglist-cont-nonempty syntax)
c-basic-offset)))))))

(defvar php-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [menu-bar php]
(cons "PHP" (make-sparse-keymap "PHP")))

(define-key map [menu-bar php complete-function]
'("Complete function name" . php-complete-function))
(define-key map [menu-bar php browse-manual]
'("Browse manual" . php-browse-manual))
(define-key map [menu-bar php search-documentation]
'("Search documentation" . php-search-documentation))

(define-key map [(control c) (control f)] 'php-search-documentation)
(define-key map [(meta tab)] 'php-complete-function)
(define-key map [(control c) (control m)] 'php-browse-manual)
(define-key map [(control .)] 'php-show-arglist)
(define-key map [(control c) (control r)] 'php-send-region)
;; Use the Emacs standard indentation binding. This may upset c-mode
;; which does not follow this at the moment, but I see no better
;; choice.
(define-key map [tab] 'indent-for-tab-command)
map)
"Keymap for `php-mode'")

;;;###autoload
(define-derived-mode php-mode c-mode "PHP"
"Major mode for editing PHP code.\n\n\\{php-mode-map}"
Expand Down Expand Up @@ -645,22 +669,6 @@ This is was done due to the problem reported here:
(set (make-local-variable 'add-log-current-defun-header-regexp)
php-beginning-of-defun-regexp))

;; Make a menu keymap (with a prompt string)
;; and make it the menu bar item's definition.
(define-key php-mode-map [menu-bar] (make-sparse-keymap))
(define-key php-mode-map [menu-bar php]
(cons "PHP" (make-sparse-keymap "PHP")))

;; Define specific subcommands in this menu.
(define-key php-mode-map [menu-bar php complete-function]
'("Complete function name" . php-complete-function))
(define-key php-mode-map
[menu-bar php browse-manual]
'("Browse manual" . php-browse-manual))
(define-key php-mode-map
[menu-bar php search-documentation]
'("Search documentation" . php-search-documentation))

;; Define function name completion function
(defvar php-completion-table nil
"Obarray of tag names defined in current tags table and functions known to PHP.")
Expand Down Expand Up @@ -828,30 +836,6 @@ searching the PHP website."
(interactive)
(browse-url php-manual-url))

;; Define shortcut
(define-key php-mode-map
"\C-c\C-f"
'php-search-documentation)

;; Define shortcut
(define-key php-mode-map
[(meta tab)]
'php-complete-function)

;; Define shortcut
(define-key php-mode-map
"\C-c\C-m"
'php-browse-manual)

;; Define shortcut
(define-key php-mode-map
'[(control .)]
'php-show-arglist)

;; Use the Emacs standard indentation binding. This may upset c-mode
;; which does not follow this at the moment, but I see no better
;; choice.
(define-key php-mode-map [?\t] 'indent-for-tab-command)

(defconst php-constants
(eval-when-compile
Expand Down Expand Up @@ -1667,8 +1651,6 @@ The output will appear in the buffer *PHP*."
code)))
(call-process "php" nil php-buffer nil "-r" (clean-php-code code)))))

(define-key php-mode-map "\C-c\C-r" 'php-send-region)


(defface php-annotations-annotation-face '((t . (:inherit 'font-lock-constant-face)))
"Face used to highlight annotations.")
Expand Down

0 comments on commit 3699aca

Please sign in to comment.