Mercurial > emacs
view lisp/progmodes/executable.el @ 110523:a5ad4f188e19
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 18 Sep 2010 22:49:54 -0400 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
line wrap: on
line source
;;; executable.el --- base functionality for executable interpreter scripts -*- byte-compile-dynamic: t -*- ;; Copyright (C) 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004, 2005, ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Daniel Pfeiffer <occitan@esperanto.org> ;; Keywords: languages, unix ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; executable.el is used by certain major modes to insert a suitable ;; #! line at the beginning of the file, if the file does not already ;; have one. ;; Unless it has a magic number, a Unix file with executable mode is passed to ;; a new instance of the running shell (or to a Bourne shell if a csh is ;; running and the file starts with `:'). Only a shell can start such a file, ;; exec() cannot, which is why it is important to have a magic number in every ;; executable script. Such a magic number is made up by the characters `#!' ;; the filename of an interpreter (in COFF, ELF or somesuch format) and one ;; optional argument. ;; This library is for certain major modes like sh-, awk-, perl-, tcl- or ;; makefile-mode to insert or update a suitable #! line at the beginning of ;; the file, if the file does not already have one and the file is not a ;; default file of that interpreter (like .profile or makefile). It also ;; makes the file executable if it wasn't, as soon as it's saved. ;; It also allows debugging scripts, with an adaptation of compile, as far ;; as interpreters give out meaningful error messages. ;; Modes that use this should nconc `executable-map' to the end of their own ;; keymap and `executable-font-lock-keywords' to the end of their own font ;; lock keywords. Their mode-setting commands should call ;; `executable-set-magic'. ;;; Code: (defgroup executable nil "Base functionality for executable interpreter scripts." :group 'processes) ;; This used to default to `other', but that doesn't seem to have any ;; significance. fx 2000-02-11. (defcustom executable-insert t ; 'other "*Non-nil means offer to add a magic number to a file. This takes effect when you switch to certain major modes, including Shell-script mode (`sh-mode'). When you type \\[executable-set-magic], it always offers to add or update the magic number." ;;; :type '(choice (const :tag "off" nil) ;;; (const :tag "on" t) ;;; symbol) :type 'boolean :group 'executable) (defcustom executable-query 'function "*If non-nil, ask user before changing an existing magic number. When this is `function', only ask when called non-interactively." :type '(choice (const :tag "Don't Ask" nil) (const :tag "Ask when non-interactive" function) (other :tag "Ask" t)) :group 'executable) (defcustom executable-magicless-file-regexp "/[Mm]akefile$\\|/\\.\\(z?profile\\|bash_profile\\|z?login\\|bash_login\\|z?logout\\|bash_logout\\|.+shrc\\|esrc\\|rcrc\\|[kz]shenv\\)$" "*On files with this kind of name no magic is inserted or changed." :type 'regexp :group 'executable) (defcustom executable-prefix "#! " "*Interpreter magic number prefix inserted when there was no magic number." :type 'string :group 'executable) (defcustom executable-chmod 73 "*After saving, if the file is not executable, set this mode. This mode passed to `set-file-modes' is taken absolutely when negative, or relative to the files existing modes. Do nothing if this is nil. Typical values are 73 (+x) or -493 (rwxr-xr-x)." :type '(choice integer (const nil)) :group 'executable) (defvar executable-command nil) (defcustom executable-self-display "tail" "*Command you use with argument `+2' to make text files self-display. Note that the like of `more' doesn't work too well under Emacs \\[shell]." :type 'string :group 'executable) (defvar executable-font-lock-keywords '(("\\`#!.*/\\([^ \t\n]+\\)" 1 font-lock-keyword-face t)) "*Rules for highlighting executable scripts' magic number. This can be included in `font-lock-keywords' by modes that call `executable'.") (defvar executable-error-regexp-alist '(;; /bin/xyz: syntax error at line 14: `(' unexpected ;; /bin/xyz[5]: syntax error at line 8 : ``' unmatched ("^\\(.*[^[/]\\)\\(\\[[0-9]+\\]\\)?: .* error .* line \\([0-9]+\\)" 1 3) ;; /bin/xyz[27]: ehco: not found ("^\\(.*[^/]\\)\\[\\([0-9]+\\)\\]: .*: " 1 2) ;; /bin/xyz: syntax error near unexpected token `)' ;; /bin/xyz: /bin/xyz: line 2: `)' ("^\\(.*[^/]\\): [^0-9\n]+\n\\1: \\1: line \\([0-9]+\\):" 1 2) ;; /usr/bin/awk: syntax error at line 5 of file /bin/xyz (" error .* line \\([0-9]+\\) of file \\(.+\\)$" 2 1) ;; /usr/bin/awk: calling undefined function toto ;; input record number 3, file awktestdata ;; source line 4 of file /bin/xyz ("^[^ ].+\n\\( .+\n\\)* line \\([0-9]+\\) of file \\(.+\\)$" 3 2) ;; makefile:1: *** target pattern contains no `%'. Stop. ("^\\(.+\\):\\([0-9]+\\): " 1 2)) "Alist of regexps used to match script errors. See `compilation-error-regexp-alist'.") ;; The C function openp slightly modified would do the trick fine (defvaralias 'executable-binary-suffixes 'exec-suffixes) ;;;###autoload (defun executable-command-find-posix-p (&optional program) "Check if PROGRAM handles arguments Posix-style. If PROGRAM is non-nil, use that instead of \"find\"." ;; Pick file to search from location we know (let* ((dir (file-truename data-directory)) (file (car (directory-files dir nil "^[^.]")))) (with-temp-buffer (call-process (or program "find") nil (current-buffer) nil dir "-name" file "-maxdepth" "1") (goto-char (point-min)) (if (search-forward file nil t) t)))) (defun executable-chmod () "This gets called after saving a file to assure that it be executable. You can set the absolute or relative mode in variable `executable-chmod' for non-executable files." (and executable-chmod buffer-file-name (or (file-executable-p buffer-file-name) (set-file-modes buffer-file-name (if (< executable-chmod 0) (- executable-chmod) (logior executable-chmod (file-modes buffer-file-name))))))) ;;;###autoload (defun executable-interpret (command) "Run script with user-specified args, and collect output in a buffer. While script runs asynchronously, you can use the \\[next-error] command to find the next error. The buffer is also in `comint-mode' and `compilation-shell-minor-mode', so that you can answer any prompts." (interactive (list (read-string "Run script: " (or executable-command buffer-file-name)))) (require 'compile) (save-some-buffers (not compilation-ask-about-save)) (set (make-local-variable 'executable-command) command) (let ((compilation-error-regexp-alist executable-error-regexp-alist)) (compilation-start command t (lambda (x) "*interpretation*")))) ;;;###autoload (defun executable-set-magic (interpreter &optional argument no-query-flag insert-flag) "Set this buffer's interpreter to INTERPRETER with optional ARGUMENT. The variables `executable-magicless-file-regexp', `executable-prefix', `executable-insert', `executable-query' and `executable-chmod' control when and how magic numbers are inserted or replaced and scripts made executable." (interactive (let* ((name (read-string "Name or file name of interpreter: ")) (arg (read-string (format "Argument for %s: " name)))) (list name arg (eq executable-query 'function) t))) (setq interpreter (if (file-name-absolute-p interpreter) interpreter (or (executable-find interpreter) (error "Interpreter %s not recognized" interpreter)))) (setq argument (concat (if (string-match "\\`/:" interpreter) (replace-match "" nil nil interpreter) interpreter) (and argument (string< "" argument) " ") argument)) (or buffer-read-only (if buffer-file-name (string-match executable-magicless-file-regexp buffer-file-name)) (not (or insert-flag executable-insert)) (> (point-min) 1) (save-excursion (goto-char (point-min)) (add-hook 'after-save-hook 'executable-chmod nil t) (if (looking-at "#![ \t]*\\(.*\\)$") (and (goto-char (match-beginning 1)) ;; If the line ends in a space, ;; don't offer to change it. (not (= (char-after (1- (match-end 1))) ?\s)) (not (string= argument (buffer-substring (point) (match-end 1)))) (if (or (not executable-query) no-query-flag (save-window-excursion ;; Make buffer visible before question. (switch-to-buffer (current-buffer)) (y-or-n-p (concat "Replace magic number by `" executable-prefix argument "'? ")))) (progn (replace-match argument t t nil 1) (message "Magic number changed to `%s'" (concat executable-prefix argument))))) (insert executable-prefix argument ?\n) (message "Magic number changed to `%s'" (concat executable-prefix argument))))) interpreter) ;;;###autoload (defun executable-self-display () "Turn a text file into a self-displaying Un*x command. The magic number of such a command displays all lines but itself." (interactive) (if (eq this-command 'executable-self-display) (setq this-command 'executable-set-magic)) (executable-set-magic executable-self-display "+2")) ;;;###autoload (defun executable-make-buffer-file-executable-if-script-p () "Make file executable according to umask if not already executable. If file already has any execute bits set at all, do not change existing file modes." (and (>= (buffer-size) 2) (save-restriction (widen) (string= "#!" (buffer-substring (point-min) (+ 2 (point-min))))) (let* ((current-mode (file-modes (buffer-file-name))) (add-mode (logand ?\111 (default-file-modes)))) (or (/= (logand ?\111 current-mode) 0) (zerop add-mode) (set-file-modes (buffer-file-name) (logior current-mode add-mode)))))) (provide 'executable) ;; arch-tag: 58458d1c-d9db-45ec-942b-8bbb1d5e319d ;;; executable.el ends here