2013-06-03 15:40:35 +00:00
|
|
|
|
;;; lisp.el --- Lisp editing commands for Emacs -*- lexical-binding:t -*-
|
1992-05-30 22:12:04 +00:00
|
|
|
|
|
2021-01-01 09:13:56 +00:00
|
|
|
|
;; Copyright (C) 1985-1986, 1994, 2000-2021 Free Software Foundation,
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Inc.
|
1992-07-22 04:22:30 +00:00
|
|
|
|
|
2019-05-25 20:43:06 +00:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1993-03-18 21:29:42 +00:00
|
|
|
|
;; Keywords: lisp, languages
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Package: emacs
|
1992-07-16 21:47:34 +00:00
|
|
|
|
|
1990-08-27 04:15:41 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1990-08-27 04:15:41 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
|
|
|
|
;; 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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
1993-03-22 03:27:18 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2000-08-20 18:12:07 +00:00
|
|
|
|
;; Lisp editing commands to go with Lisp major mode. More-or-less
|
|
|
|
|
;; applicable in other modes too.
|
1993-03-22 03:27:18 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
1994-03-15 23:36:48 +00:00
|
|
|
|
;; Note that this variable is used by non-lisp modes too.
|
1997-05-05 15:06:25 +00:00
|
|
|
|
(defcustom defun-prompt-regexp nil
|
2009-07-22 02:45:34 +00:00
|
|
|
|
"If non-nil, a regexp to ignore before a defun.
|
1994-03-15 23:36:48 +00:00
|
|
|
|
This is only necessary if the opening paren or brace is not in column 0.
|
2005-04-08 23:10:24 +00:00
|
|
|
|
See function `beginning-of-defun'."
|
1997-09-09 02:57:48 +00:00
|
|
|
|
:type '(choice (const nil)
|
|
|
|
|
regexp)
|
1997-05-05 15:06:25 +00:00
|
|
|
|
:group 'lisp)
|
1994-04-20 01:11:35 +00:00
|
|
|
|
(make-variable-buffer-local 'defun-prompt-regexp)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
1997-05-05 15:06:25 +00:00
|
|
|
|
(defcustom parens-require-spaces t
|
2008-03-05 20:54:56 +00:00
|
|
|
|
"If non-nil, add whitespace as needed when inserting parentheses.
|
|
|
|
|
This affects `insert-parentheses' and `insert-pair'."
|
1997-05-05 15:06:25 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'lisp)
|
1993-06-14 22:58:54 +00:00
|
|
|
|
|
2000-09-29 03:30:04 +00:00
|
|
|
|
(defvar forward-sexp-function nil
|
2013-04-17 20:52:02 +00:00
|
|
|
|
;; FIXME:
|
|
|
|
|
;; - for some uses, we may want a "sexp-only" version, which only
|
|
|
|
|
;; jumps over a well-formed sexp, rather than some dwimish thing
|
|
|
|
|
;; like jumping from an "else" back up to its "if".
|
|
|
|
|
;; - for up-list, we could use the "sexp-only" behavior as well
|
|
|
|
|
;; to treat the dwimish halfsexp as a form of "up-list" step.
|
2000-09-29 03:30:04 +00:00
|
|
|
|
"If non-nil, `forward-sexp' delegates to this function.
|
|
|
|
|
Should take the same arguments and behave similarly to `forward-sexp'.")
|
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun forward-sexp (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move forward across one balanced expression (sexp).
|
2014-04-09 16:58:08 +00:00
|
|
|
|
With ARG, do it that many times. Negative arg -N means move
|
|
|
|
|
backward across N balanced expressions. This command assumes
|
|
|
|
|
point is not in a string or comment. Calls
|
lisp/*.el: Fix typos and other trivial doc fixes
* lisp/allout-widgets.el (allout-widgets-auto-activation)
(allout-current-decorated-p):
* lisp/auth-source.el (auth-source-protocols):
* lisp/autorevert.el (auto-revert-set-timer):
* lisp/battery.el (battery-mode-line-limit):
* lisp/calc/calcalg3.el (math-map-binop):
* lisp/calendar/cal-dst.el (calendar-dst-find-startend):
* lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute):
* lisp/calendar/calendar.el (calendar-date-echo-text)
(calendar-generate-month, calendar-string-spread)
(calendar-cursor-to-date, calendar-read, calendar-read-date)
(calendar-mark-visible-date, calendar-dayname-on-or-before):
* lisp/calendar/diary-lib.el (diary-ordinal-suffix):
* lisp/cedet/ede/autoconf-edit.el (autoconf-new-program)
(autoconf-find-last-macro, autoconf-parameter-strip):
* lisp/cedet/ede/config.el (ede-target-with-config-build):
* lisp/cedet/ede/linux.el (ede-linux--detect-architecture)
(ede-linux--get-architecture):
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache)
(semantic-displayer-abstract, semantic-displayer-point-position):
* lisp/cedet/semantic/format.el (semantic-format-face-alist)
(semantic-format-tag-short-doc):
* lisp/cedet/semantic/fw.el (semantic-find-file-noselect):
* lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time)
(semantic-idle-breadcrumbs-display-function)
(semantic-idle-breadcrumbs-format-tag-list-function):
* lisp/cedet/semantic/lex.el (semantic-lex-map-types)
(define-lex, define-lex-block-type-analyzer):
* lisp/cedet/semantic/senator.el (senator-search-default-tag-filter):
* lisp/cedet/semantic/symref.el (semantic-symref-result)
(semantic-symref-hit-to-tag-via-db):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass):
* lisp/cedet/semantic/tag.el (semantic-tag-new-variable)
(semantic-tag-new-include, semantic-tag-new-package)
(semantic-tag-set-faux, semantic-create-tag-proxy)
(semantic-tag-function-parent)
(semantic-tag-components-with-overlays):
* lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces)
(srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict):
* lisp/cedet/srecode/dictionary.el (srecode-create-dictionary)
(srecode-dictionary-add-entries, srecode-dictionary-lookup-name)
(srecode-create-dictionaries-from-tags):
* lisp/cmuscheme.el (scheme-compile-region):
* lisp/color.el (color-lab-to-lch):
* lisp/doc-view.el (doc-view-image-width)
(doc-view-set-up-single-converter):
* lisp/dynamic-setting.el (font-setting-change-default-font)
(dynamic-setting-handle-config-changed-event):
* lisp/elec-pair.el (electric-pair-text-pairs)
(electric-pair-skip-whitespace-function)
(electric-pair-string-bound-function):
* lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance)
(avl-tree-member, avl-tree-mapcar, avl-tree-iter):
* lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree):
* lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag)
(checkdoc-spellcheck-documentation-flag, checkdoc-ispell)
(checkdoc-ispell-current-buffer, checkdoc-ispell-interactive)
(checkdoc-ispell-message-interactive)
(checkdoc-ispell-message-text, checkdoc-ispell-start)
(checkdoc-ispell-continue, checkdoc-ispell-comments)
(checkdoc-ispell-defun):
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method):
* lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group):
* lisp/emacs-lisp/lisp.el (forward-sexp, up-list):
* lisp/emacs-lisp/package-x.el (package--archive-contents-from-file):
* lisp/emacs-lisp/package.el (package-desc)
(package--make-autoloads-and-stuff, package-hidden-regexps):
* lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup):
* lisp/emacs-lisp/testcover.el (testcover-nohits)
(testcover-1value):
* lisp/epg.el (epg-receive-keys, epg-start-edit-key):
* lisp/erc/erc-backend.el (erc-server-processing-p)
(erc-split-line-length, erc-server-coding-system)
(erc-server-send, erc-message):
* lisp/erc/erc-button.el (erc-button-face, erc-button-alist)
(erc-browse-emacswiki):
* lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login):
* lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation):
* lisp/erc/erc-log.el (erc-current-logfile):
* lisp/erc/erc-match.el (erc-log-match-format)
(erc-text-matched-hook):
* lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug):
* lisp/erc/erc-networks.el (erc-server-alist)
(erc-networks-alist, erc-current-network):
* lisp/erc/erc-ring.el (erc-input-ring-index):
* lisp/erc/erc-speedbar.el (erc-speedbar)
(erc-speedbar-update-channel):
* lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag):
* lisp/erc/erc-track.el (erc-track-position-in-mode-line)
(erc-track-remove-from-mode-line, erc-modified-channels-update)
(erc-track-last-non-erc-buffer, erc-track-sort-by-importance)
(erc-track-get-active-buffer):
* lisp/erc/erc.el (erc-get-channel-user-list)
(erc-echo-notice-hook, erc-echo-notice-always-hook)
(erc-wash-quit-reason, erc-format-@nick):
* lisp/ffap.el (ffap-latex-mode):
* lisp/files.el (abort-if-file-too-large)
(dir-locals--get-sort-score, buffer-stale--default-function):
* lisp/filesets.el (filesets-tree-max-level, filesets-data)
(filesets-update-pre010505):
* lisp/gnus/gnus-agent.el (gnus-agent-flush-cache):
* lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol)
(gnus-button-prefer-mid-or-mail):
* lisp/gnus/gnus-cus.el (gnus-group-parameters):
* lisp/gnus/gnus-demon.el (gnus-demon-handlers)
(gnus-demon-run-callback):
* lisp/gnus/gnus-dired.el (gnus-dired-print):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer):
* lisp/gnus/gnus-range.el (gnus-range-normalize):
* lisp/gnus/gnus-spec.el (gnus-pad-form):
* lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud)
(gnus-server-opened, gnus-server-closed, gnus-server-denied)
(gnus-server-offline):
* lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir)
(gnus-refer-thread-limit-to-thread)
(gnus-summary-limit-include-thread, gnus-summary-refer-thread)
(gnus-summary-find-matching):
* lisp/gnus/gnus-util.el (gnus-rescale-image):
* lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server):
* lisp/gnus/mail-source.el (mail-source-incoming-file-prefix):
* lisp/gnus/message.el (message-cite-reply-position)
(message-cite-style-outlook, message-cite-style-thunderbird)
(message-cite-style-gmail, message--send-mail-maybe-partially):
* lisp/gnus/mm-extern.el (mm-inline-external-body):
* lisp/gnus/mm-partial.el (mm-inline-partial):
* lisp/gnus/mml-sec.el (mml-secure-message-sign)
(mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
* lisp/gnus/mml2015.el (mml2015-epg-key-image)
(mml2015-epg-key-image-to-string):
* lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail):
* lisp/gnus/nnheader.el (nnheader-directory-files-is-safe):
* lisp/gnus/nnir.el (nnir-search-history)
(nnir-imap-search-other, nnir-artlist-length)
(nnir-artlist-article, nnir-artitem-group, nnir-artitem-number)
(nnir-artitem-rsv, nnir-article-group, nnir-article-number)
(nnir-article-rsv, nnir-article-ids, nnir-categorize)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-hyrex-additional-switches)
(gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms)
(nnir-read-parm, nnir-read-server-parm, nnir-search-thread):
* lisp/gnus/nnmairix.el (nnmairix-default-group)
(nnmairix-propagate-marks):
* lisp/gnus/smime.el (smime-keys, smime-crl-check)
(smime-verify-buffer, smime-noverify-buffer):
* lisp/gnus/spam-report.el (spam-report-url-ping-mm-url):
* lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header)
(spam-spamassassin-spam-status-header, spam-sa-learn-rebuild)
(spam-classifications, spam-check-stat, spam-spamassassin-score):
* lisp/help.el (describe-minor-mode-from-symbol):
* lisp/hippie-exp.el (hippie-expand-ignore-buffers):
* lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face)
(hfy-begin-span):
* lisp/ibuf-ext.el (ibuffer-update-saved-filters-format)
(ibuffer-saved-filters, ibuffer-old-saved-filters-warning)
(ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters)
(eval, ibuffer-unary-operand, file-extension, directory):
* lisp/image-dired.el (image-dired-cmd-pngcrush-options):
* lisp/image-mode.el (image-toggle-display):
* lisp/international/ccl.el (ccl-compile-read-multibyte-character)
(ccl-compile-write-multibyte-character):
* lisp/international/kkc.el (kkc-save-init-file):
* lisp/international/latin1-disp.el (latin1-display):
* lisp/international/ogonek.el (ogonek-name-encoding-alist)
(ogonek-information, ogonek-lookup-encoding)
(ogonek-deprefixify-region):
* lisp/isearch.el (isearch-filter-predicate)
(isearch--momentary-message):
* lisp/jsonrpc.el (jsonrpc-connection-send)
(jsonrpc-process-connection, jsonrpc-shutdown)
(jsonrpc--async-request-1):
* lisp/language/tibet-util.el (tibetan-char-p):
* lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date)
(feedmail-last-chance-hook, feedmail-before-fcc-hook)
(feedmail-send-it-immediately-wrapper, feedmail-find-eoh):
* lisp/mail/hashcash.el (hashcash-generate-payment)
(hashcash-generate-payment-async, hashcash-insert-payment)
(hashcash-verify-payment):
* lisp/mail/rmail.el (rmail-movemail-variant-in-use)
(rmail-get-attr-value):
* lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime):
* lisp/mail/rmailsum.el (rmail-summary-show-message):
* lisp/mail/supercite.el (sc-raw-mode-toggle):
* lisp/man.el (Man-start-calling):
* lisp/mh-e/mh-acros.el (mh-do-at-event-location)
(mh-iterate-on-messages-in-region, mh-iterate-on-range):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases)
(mh-alias-reload, mh-alias-ali)
(mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file)
(mh-alias-add-alias):
* lisp/mouse.el (mouse-save-then-kill):
* lisp/net/browse-url.el (browse-url-default-macosx-browser):
* lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value)
(eudc-variable-server-value, eudc-update-variable)
(eudc-expand-inline):
* lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result):
* lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list):
* lisp/net/pop3.el (pop3-list):
* lisp/net/soap-client.el (soap-namespace-put)
(soap-xs-parse-sequence, soap-parse-envelope):
* lisp/net/soap-inspect.el (soap-inspect-xs-complex-type):
* lisp/nxml/rng-xsd.el (rng-xsd-date-to-days):
* lisp/org/ob-C.el (org-babel-prep-session:C)
(org-babel-load-session:C):
* lisp/org/ob-J.el (org-babel-execute:J):
* lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* lisp/org/ob-core.el (org-babel-process-file-name):
* lisp/org/ob-ebnf.el (org-babel-execute:ebnf):
* lisp/org/ob-forth.el (org-babel-execute:forth):
* lisp/org/ob-fortran.el (org-babel-execute:fortran)
(org-babel-prep-session:fortran, org-babel-load-session:fortran):
* lisp/org/ob-groovy.el (org-babel-execute:groovy):
* lisp/org/ob-io.el (org-babel-execute:io):
* lisp/org/ob-js.el (org-babel-execute:js):
* lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond)
(org-babel-lilypond-compile-post-tangle)
(org-babel-lilypond-display-pdf-post-tangle)
(org-babel-lilypond-tangle)
(org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-compile-lilyfile)
(org-babel-lilypond-check-for-compile-error)
(org-babel-lilypond-process-compile-error)
(org-babel-lilypond-mark-error-line)
(org-babel-lilypond-parse-error-line)
(org-babel-lilypond-attempt-to-open-pdf)
(org-babel-lilypond-attempt-to-play-midi)
(org-babel-lilypond-switch-extension)
(org-babel-lilypond-set-header-args):
* lisp/org/ob-lua.el (org-babel-prep-session:lua):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-processing.el (org-babel-prep-session:processing):
* lisp/org/ob-python.el (org-babel-prep-session:python):
* lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message)
(org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/org-agenda.el (org-agenda-entry-types)
(org-agenda-move-date-from-past-immediately-to-today)
(org-agenda-time-grid, org-agenda-sorting-strategy)
(org-agenda-filter-by-category, org-agenda-forward-block):
* lisp/org/org-colview.el (org-columns--overlay-text):
* lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces):
* lisp/org/org-indent.el (org-indent-set-line-properties):
* lisp/org/org-macs.el (org-get-limited-outline-regexp):
* lisp/org/org-mobile.el (org-mobile-files):
* lisp/org/org.el (org-use-fast-todo-selection)
(org-extend-today-until, org-use-property-inheritance)
(org-refresh-effort-properties, org-open-at-point-global)
(org-track-ordered-property-with-tag, org-shiftright):
* lisp/org/ox-html.el (org-html-checkbox-type):
* lisp/org/ox-man.el (org-man-source-highlight)
(org-man-verse-block):
* lisp/org/ox-publish.el (org-publish-sitemap-default):
* lisp/outline.el (outline-head-from-level):
* lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-calc-command-indent, dcl-indent-to):
* lisp/progmodes/flymake.el (flymake-make-diagnostic)
(flymake--overlays, flymake-diagnostic-functions)
(flymake-diagnostic-types-alist, flymake--backend-state)
(flymake-is-running, flymake--collect, flymake-mode):
* lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop)
(gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer):
* lisp/progmodes/grep.el (grep-error-screen-columns):
* lisp/progmodes/gud.el (gud-prev-expr):
* lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column)
(ps-run-goto-error):
* lisp/progmodes/python.el (python-eldoc-get-doc)
(python-eldoc-function-timeout-permanent, python-eldoc-function):
* lisp/shadowfile.el (shadow-make-group):
* lisp/speedbar.el (speedbar-obj-do-check):
* lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook):
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib):
* lisp/textmodes/reftex-index.el (reftex-index-goto-entry)
(reftex-index-kill, reftex-index-undo):
* lisp/textmodes/reftex-parse.el (reftex-context-substring):
* lisp/textmodes/reftex.el (reftex-TeX-master-file):
* lisp/textmodes/rst.el (rst-next-hdr, rst-toc)
(rst-uncomment-region, rst-font-lock-extend-region-internal):
* lisp/thumbs.el (thumbs-mode):
* lisp/vc/ediff-util.el (ediff-restore-diff):
* lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag):
* lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p):
* lisp/wid-edit.el (widget-field-value-set, string):
* lisp/x-dnd.el (x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
|
|
|
|
`forward-sexp-function' to do the work, if that is non-nil.
|
|
|
|
|
If unable to move over a sexp, signal `scan-error' with three
|
2014-04-09 16:58:08 +00:00
|
|
|
|
arguments: a message, the start of the obstacle (usually a
|
|
|
|
|
parenthesis or list marker of some kind), and end of the
|
2020-09-23 16:08:32 +00:00
|
|
|
|
obstacle. If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "^p\nd")
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(if interactive
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case _
|
|
|
|
|
(forward-sexp arg nil)
|
|
|
|
|
(scan-error (user-error (if (> arg 0)
|
|
|
|
|
"No next sexp"
|
|
|
|
|
"No previous sexp"))))
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(if forward-sexp-function
|
|
|
|
|
(funcall forward-sexp-function arg)
|
|
|
|
|
(goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
|
|
|
|
|
(if (< arg 0) (backward-prefix-chars)))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun backward-sexp (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move backward across one balanced expression (sexp).
|
2000-01-05 15:08:36 +00:00
|
|
|
|
With ARG, do it that many times. Negative arg -N means
|
2008-11-26 10:30:53 +00:00
|
|
|
|
move forward across N balanced expressions.
|
2013-06-13 16:44:26 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
Uses `forward-sexp' to do the work.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "^p\nd")
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(forward-sexp (- arg) interactive))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2004-12-29 01:32:06 +00:00
|
|
|
|
(defun mark-sexp (&optional arg allow-extend)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Set mark ARG sexps from point.
|
1991-03-12 20:00:05 +00:00
|
|
|
|
The place mark goes is the same place \\[forward-sexp] would
|
2001-11-19 22:06:10 +00:00
|
|
|
|
move to with the same argument.
|
2004-12-29 01:32:06 +00:00
|
|
|
|
Interactively, if this command is repeated
|
2005-04-08 23:10:24 +00:00
|
|
|
|
or (in Transient Mark mode) if the mark is active,
|
2008-11-26 10:30:53 +00:00
|
|
|
|
it marks the next ARG sexps after the ones already marked.
|
|
|
|
|
This command assumes point is not in a string or comment."
|
2004-12-29 01:32:06 +00:00
|
|
|
|
(interactive "P\np")
|
|
|
|
|
(cond ((and allow-extend
|
|
|
|
|
(or (and (eq last-command this-command) (mark t))
|
|
|
|
|
(and transient-mark-mode mark-active)))
|
2004-10-12 16:05:55 +00:00
|
|
|
|
(setq arg (if arg (prefix-numeric-value arg)
|
2004-12-13 03:09:59 +00:00
|
|
|
|
(if (< (mark) (point)) -1 1)))
|
2002-02-15 08:53:15 +00:00
|
|
|
|
(set-mark
|
|
|
|
|
(save-excursion
|
2004-12-13 03:09:59 +00:00
|
|
|
|
(goto-char (mark))
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case error
|
|
|
|
|
(forward-sexp arg)
|
|
|
|
|
(scan-error
|
|
|
|
|
(user-error (if (equal (cadr error)
|
|
|
|
|
"Containing expression ends prematurely")
|
|
|
|
|
"No more sexp to select"
|
|
|
|
|
(cadr error)))))
|
2004-12-13 03:09:59 +00:00
|
|
|
|
(point))))
|
2002-02-15 08:53:15 +00:00
|
|
|
|
(t
|
|
|
|
|
(push-mark
|
|
|
|
|
(save-excursion
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case error
|
|
|
|
|
(forward-sexp (prefix-numeric-value arg))
|
|
|
|
|
(scan-error
|
|
|
|
|
(user-error (if (equal (cadr error)
|
|
|
|
|
"Containing expression ends prematurely")
|
|
|
|
|
"No sexp to select"
|
|
|
|
|
(cadr error)))))
|
2002-02-15 08:53:15 +00:00
|
|
|
|
(point))
|
|
|
|
|
nil t))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun forward-list (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move forward across one balanced group of parentheses.
|
2014-02-10 05:50:16 +00:00
|
|
|
|
This command will also work on other parentheses-like expressions
|
|
|
|
|
defined by the current language mode.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
With ARG, do it that many times.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
Negative arg -N means move backward across N groups of parentheses.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "^p\nd")
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(if interactive
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case _
|
|
|
|
|
(forward-list arg nil)
|
|
|
|
|
(scan-error (user-error (if (> arg 0)
|
|
|
|
|
"No next group"
|
|
|
|
|
"No previous group"))))
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(goto-char (or (scan-lists (point) arg 0) (buffer-end arg)))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun backward-list (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move backward across one balanced group of parentheses.
|
2014-02-10 05:50:16 +00:00
|
|
|
|
This command will also work on other parentheses-like expressions
|
|
|
|
|
defined by the current language mode.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
With ARG, do it that many times.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
Negative arg -N means move forward across N groups of parentheses.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "^p\nd")
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(forward-list (- arg) interactive))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun down-list (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move forward down one level of parentheses.
|
2014-02-10 05:50:16 +00:00
|
|
|
|
This command will also work on other parentheses-like expressions
|
|
|
|
|
defined by the current language mode.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
With ARG, do this that many times.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
A negative argument means move backward but still go down a level.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "^p\nd")
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(if interactive
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case _
|
|
|
|
|
(down-list arg nil)
|
|
|
|
|
(scan-error (user-error "At bottom level")))
|
|
|
|
|
(or arg (setq arg 1))
|
|
|
|
|
(let ((inc (if (> arg 0) 1 -1)))
|
|
|
|
|
(while (/= arg 0)
|
|
|
|
|
(goto-char (or (scan-lists (point) inc -1) (buffer-end arg)))
|
|
|
|
|
(setq arg (- arg inc))))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2014-04-09 16:58:08 +00:00
|
|
|
|
(defun backward-up-list (&optional arg escape-strings no-syntax-crossing)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move backward out of one level of parentheses.
|
2014-02-10 05:50:16 +00:00
|
|
|
|
This command will also work on other parentheses-like expressions
|
2014-04-09 16:58:08 +00:00
|
|
|
|
defined by the current language mode. With ARG, do this that
|
|
|
|
|
many times. A negative argument means move forward but still to
|
|
|
|
|
a less deep spot. If ESCAPE-STRINGS is non-nil (as it is
|
|
|
|
|
interactively), move out of enclosing strings as well. If
|
|
|
|
|
NO-SYNTAX-CROSSING is non-nil (as it is interactively), prefer to
|
|
|
|
|
break out of any enclosing string instead of moving to the start
|
|
|
|
|
of a list broken across multiple strings. On error, location of
|
|
|
|
|
point is unspecified."
|
|
|
|
|
(interactive "^p\nd\nd")
|
|
|
|
|
(up-list (- (or arg 1)) escape-strings no-syntax-crossing))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2014-04-09 16:58:08 +00:00
|
|
|
|
(defun up-list (&optional arg escape-strings no-syntax-crossing)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Move forward out of one level of parentheses.
|
2014-02-10 05:50:16 +00:00
|
|
|
|
This command will also work on other parentheses-like expressions
|
2014-04-09 16:58:08 +00:00
|
|
|
|
defined by the current language mode. With ARG, do this that
|
|
|
|
|
many times. A negative argument means move backward but still to
|
|
|
|
|
a less deep spot. If ESCAPE-STRINGS is non-nil (as it is
|
lisp/*.el: Fix typos and other trivial doc fixes
* lisp/allout-widgets.el (allout-widgets-auto-activation)
(allout-current-decorated-p):
* lisp/auth-source.el (auth-source-protocols):
* lisp/autorevert.el (auto-revert-set-timer):
* lisp/battery.el (battery-mode-line-limit):
* lisp/calc/calcalg3.el (math-map-binop):
* lisp/calendar/cal-dst.el (calendar-dst-find-startend):
* lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute):
* lisp/calendar/calendar.el (calendar-date-echo-text)
(calendar-generate-month, calendar-string-spread)
(calendar-cursor-to-date, calendar-read, calendar-read-date)
(calendar-mark-visible-date, calendar-dayname-on-or-before):
* lisp/calendar/diary-lib.el (diary-ordinal-suffix):
* lisp/cedet/ede/autoconf-edit.el (autoconf-new-program)
(autoconf-find-last-macro, autoconf-parameter-strip):
* lisp/cedet/ede/config.el (ede-target-with-config-build):
* lisp/cedet/ede/linux.el (ede-linux--detect-architecture)
(ede-linux--get-architecture):
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache)
(semantic-displayer-abstract, semantic-displayer-point-position):
* lisp/cedet/semantic/format.el (semantic-format-face-alist)
(semantic-format-tag-short-doc):
* lisp/cedet/semantic/fw.el (semantic-find-file-noselect):
* lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time)
(semantic-idle-breadcrumbs-display-function)
(semantic-idle-breadcrumbs-format-tag-list-function):
* lisp/cedet/semantic/lex.el (semantic-lex-map-types)
(define-lex, define-lex-block-type-analyzer):
* lisp/cedet/semantic/senator.el (senator-search-default-tag-filter):
* lisp/cedet/semantic/symref.el (semantic-symref-result)
(semantic-symref-hit-to-tag-via-db):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass):
* lisp/cedet/semantic/tag.el (semantic-tag-new-variable)
(semantic-tag-new-include, semantic-tag-new-package)
(semantic-tag-set-faux, semantic-create-tag-proxy)
(semantic-tag-function-parent)
(semantic-tag-components-with-overlays):
* lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces)
(srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict):
* lisp/cedet/srecode/dictionary.el (srecode-create-dictionary)
(srecode-dictionary-add-entries, srecode-dictionary-lookup-name)
(srecode-create-dictionaries-from-tags):
* lisp/cmuscheme.el (scheme-compile-region):
* lisp/color.el (color-lab-to-lch):
* lisp/doc-view.el (doc-view-image-width)
(doc-view-set-up-single-converter):
* lisp/dynamic-setting.el (font-setting-change-default-font)
(dynamic-setting-handle-config-changed-event):
* lisp/elec-pair.el (electric-pair-text-pairs)
(electric-pair-skip-whitespace-function)
(electric-pair-string-bound-function):
* lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance)
(avl-tree-member, avl-tree-mapcar, avl-tree-iter):
* lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree):
* lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag)
(checkdoc-spellcheck-documentation-flag, checkdoc-ispell)
(checkdoc-ispell-current-buffer, checkdoc-ispell-interactive)
(checkdoc-ispell-message-interactive)
(checkdoc-ispell-message-text, checkdoc-ispell-start)
(checkdoc-ispell-continue, checkdoc-ispell-comments)
(checkdoc-ispell-defun):
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method):
* lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group):
* lisp/emacs-lisp/lisp.el (forward-sexp, up-list):
* lisp/emacs-lisp/package-x.el (package--archive-contents-from-file):
* lisp/emacs-lisp/package.el (package-desc)
(package--make-autoloads-and-stuff, package-hidden-regexps):
* lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup):
* lisp/emacs-lisp/testcover.el (testcover-nohits)
(testcover-1value):
* lisp/epg.el (epg-receive-keys, epg-start-edit-key):
* lisp/erc/erc-backend.el (erc-server-processing-p)
(erc-split-line-length, erc-server-coding-system)
(erc-server-send, erc-message):
* lisp/erc/erc-button.el (erc-button-face, erc-button-alist)
(erc-browse-emacswiki):
* lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login):
* lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation):
* lisp/erc/erc-log.el (erc-current-logfile):
* lisp/erc/erc-match.el (erc-log-match-format)
(erc-text-matched-hook):
* lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug):
* lisp/erc/erc-networks.el (erc-server-alist)
(erc-networks-alist, erc-current-network):
* lisp/erc/erc-ring.el (erc-input-ring-index):
* lisp/erc/erc-speedbar.el (erc-speedbar)
(erc-speedbar-update-channel):
* lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag):
* lisp/erc/erc-track.el (erc-track-position-in-mode-line)
(erc-track-remove-from-mode-line, erc-modified-channels-update)
(erc-track-last-non-erc-buffer, erc-track-sort-by-importance)
(erc-track-get-active-buffer):
* lisp/erc/erc.el (erc-get-channel-user-list)
(erc-echo-notice-hook, erc-echo-notice-always-hook)
(erc-wash-quit-reason, erc-format-@nick):
* lisp/ffap.el (ffap-latex-mode):
* lisp/files.el (abort-if-file-too-large)
(dir-locals--get-sort-score, buffer-stale--default-function):
* lisp/filesets.el (filesets-tree-max-level, filesets-data)
(filesets-update-pre010505):
* lisp/gnus/gnus-agent.el (gnus-agent-flush-cache):
* lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol)
(gnus-button-prefer-mid-or-mail):
* lisp/gnus/gnus-cus.el (gnus-group-parameters):
* lisp/gnus/gnus-demon.el (gnus-demon-handlers)
(gnus-demon-run-callback):
* lisp/gnus/gnus-dired.el (gnus-dired-print):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer):
* lisp/gnus/gnus-range.el (gnus-range-normalize):
* lisp/gnus/gnus-spec.el (gnus-pad-form):
* lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud)
(gnus-server-opened, gnus-server-closed, gnus-server-denied)
(gnus-server-offline):
* lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir)
(gnus-refer-thread-limit-to-thread)
(gnus-summary-limit-include-thread, gnus-summary-refer-thread)
(gnus-summary-find-matching):
* lisp/gnus/gnus-util.el (gnus-rescale-image):
* lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server):
* lisp/gnus/mail-source.el (mail-source-incoming-file-prefix):
* lisp/gnus/message.el (message-cite-reply-position)
(message-cite-style-outlook, message-cite-style-thunderbird)
(message-cite-style-gmail, message--send-mail-maybe-partially):
* lisp/gnus/mm-extern.el (mm-inline-external-body):
* lisp/gnus/mm-partial.el (mm-inline-partial):
* lisp/gnus/mml-sec.el (mml-secure-message-sign)
(mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
* lisp/gnus/mml2015.el (mml2015-epg-key-image)
(mml2015-epg-key-image-to-string):
* lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail):
* lisp/gnus/nnheader.el (nnheader-directory-files-is-safe):
* lisp/gnus/nnir.el (nnir-search-history)
(nnir-imap-search-other, nnir-artlist-length)
(nnir-artlist-article, nnir-artitem-group, nnir-artitem-number)
(nnir-artitem-rsv, nnir-article-group, nnir-article-number)
(nnir-article-rsv, nnir-article-ids, nnir-categorize)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-hyrex-additional-switches)
(gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms)
(nnir-read-parm, nnir-read-server-parm, nnir-search-thread):
* lisp/gnus/nnmairix.el (nnmairix-default-group)
(nnmairix-propagate-marks):
* lisp/gnus/smime.el (smime-keys, smime-crl-check)
(smime-verify-buffer, smime-noverify-buffer):
* lisp/gnus/spam-report.el (spam-report-url-ping-mm-url):
* lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header)
(spam-spamassassin-spam-status-header, spam-sa-learn-rebuild)
(spam-classifications, spam-check-stat, spam-spamassassin-score):
* lisp/help.el (describe-minor-mode-from-symbol):
* lisp/hippie-exp.el (hippie-expand-ignore-buffers):
* lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face)
(hfy-begin-span):
* lisp/ibuf-ext.el (ibuffer-update-saved-filters-format)
(ibuffer-saved-filters, ibuffer-old-saved-filters-warning)
(ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters)
(eval, ibuffer-unary-operand, file-extension, directory):
* lisp/image-dired.el (image-dired-cmd-pngcrush-options):
* lisp/image-mode.el (image-toggle-display):
* lisp/international/ccl.el (ccl-compile-read-multibyte-character)
(ccl-compile-write-multibyte-character):
* lisp/international/kkc.el (kkc-save-init-file):
* lisp/international/latin1-disp.el (latin1-display):
* lisp/international/ogonek.el (ogonek-name-encoding-alist)
(ogonek-information, ogonek-lookup-encoding)
(ogonek-deprefixify-region):
* lisp/isearch.el (isearch-filter-predicate)
(isearch--momentary-message):
* lisp/jsonrpc.el (jsonrpc-connection-send)
(jsonrpc-process-connection, jsonrpc-shutdown)
(jsonrpc--async-request-1):
* lisp/language/tibet-util.el (tibetan-char-p):
* lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date)
(feedmail-last-chance-hook, feedmail-before-fcc-hook)
(feedmail-send-it-immediately-wrapper, feedmail-find-eoh):
* lisp/mail/hashcash.el (hashcash-generate-payment)
(hashcash-generate-payment-async, hashcash-insert-payment)
(hashcash-verify-payment):
* lisp/mail/rmail.el (rmail-movemail-variant-in-use)
(rmail-get-attr-value):
* lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime):
* lisp/mail/rmailsum.el (rmail-summary-show-message):
* lisp/mail/supercite.el (sc-raw-mode-toggle):
* lisp/man.el (Man-start-calling):
* lisp/mh-e/mh-acros.el (mh-do-at-event-location)
(mh-iterate-on-messages-in-region, mh-iterate-on-range):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases)
(mh-alias-reload, mh-alias-ali)
(mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file)
(mh-alias-add-alias):
* lisp/mouse.el (mouse-save-then-kill):
* lisp/net/browse-url.el (browse-url-default-macosx-browser):
* lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value)
(eudc-variable-server-value, eudc-update-variable)
(eudc-expand-inline):
* lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result):
* lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list):
* lisp/net/pop3.el (pop3-list):
* lisp/net/soap-client.el (soap-namespace-put)
(soap-xs-parse-sequence, soap-parse-envelope):
* lisp/net/soap-inspect.el (soap-inspect-xs-complex-type):
* lisp/nxml/rng-xsd.el (rng-xsd-date-to-days):
* lisp/org/ob-C.el (org-babel-prep-session:C)
(org-babel-load-session:C):
* lisp/org/ob-J.el (org-babel-execute:J):
* lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* lisp/org/ob-core.el (org-babel-process-file-name):
* lisp/org/ob-ebnf.el (org-babel-execute:ebnf):
* lisp/org/ob-forth.el (org-babel-execute:forth):
* lisp/org/ob-fortran.el (org-babel-execute:fortran)
(org-babel-prep-session:fortran, org-babel-load-session:fortran):
* lisp/org/ob-groovy.el (org-babel-execute:groovy):
* lisp/org/ob-io.el (org-babel-execute:io):
* lisp/org/ob-js.el (org-babel-execute:js):
* lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond)
(org-babel-lilypond-compile-post-tangle)
(org-babel-lilypond-display-pdf-post-tangle)
(org-babel-lilypond-tangle)
(org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-compile-lilyfile)
(org-babel-lilypond-check-for-compile-error)
(org-babel-lilypond-process-compile-error)
(org-babel-lilypond-mark-error-line)
(org-babel-lilypond-parse-error-line)
(org-babel-lilypond-attempt-to-open-pdf)
(org-babel-lilypond-attempt-to-play-midi)
(org-babel-lilypond-switch-extension)
(org-babel-lilypond-set-header-args):
* lisp/org/ob-lua.el (org-babel-prep-session:lua):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-processing.el (org-babel-prep-session:processing):
* lisp/org/ob-python.el (org-babel-prep-session:python):
* lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message)
(org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/org-agenda.el (org-agenda-entry-types)
(org-agenda-move-date-from-past-immediately-to-today)
(org-agenda-time-grid, org-agenda-sorting-strategy)
(org-agenda-filter-by-category, org-agenda-forward-block):
* lisp/org/org-colview.el (org-columns--overlay-text):
* lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces):
* lisp/org/org-indent.el (org-indent-set-line-properties):
* lisp/org/org-macs.el (org-get-limited-outline-regexp):
* lisp/org/org-mobile.el (org-mobile-files):
* lisp/org/org.el (org-use-fast-todo-selection)
(org-extend-today-until, org-use-property-inheritance)
(org-refresh-effort-properties, org-open-at-point-global)
(org-track-ordered-property-with-tag, org-shiftright):
* lisp/org/ox-html.el (org-html-checkbox-type):
* lisp/org/ox-man.el (org-man-source-highlight)
(org-man-verse-block):
* lisp/org/ox-publish.el (org-publish-sitemap-default):
* lisp/outline.el (outline-head-from-level):
* lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-calc-command-indent, dcl-indent-to):
* lisp/progmodes/flymake.el (flymake-make-diagnostic)
(flymake--overlays, flymake-diagnostic-functions)
(flymake-diagnostic-types-alist, flymake--backend-state)
(flymake-is-running, flymake--collect, flymake-mode):
* lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop)
(gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer):
* lisp/progmodes/grep.el (grep-error-screen-columns):
* lisp/progmodes/gud.el (gud-prev-expr):
* lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column)
(ps-run-goto-error):
* lisp/progmodes/python.el (python-eldoc-get-doc)
(python-eldoc-function-timeout-permanent, python-eldoc-function):
* lisp/shadowfile.el (shadow-make-group):
* lisp/speedbar.el (speedbar-obj-do-check):
* lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook):
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib):
* lisp/textmodes/reftex-index.el (reftex-index-goto-entry)
(reftex-index-kill, reftex-index-undo):
* lisp/textmodes/reftex-parse.el (reftex-context-substring):
* lisp/textmodes/reftex.el (reftex-TeX-master-file):
* lisp/textmodes/rst.el (rst-next-hdr, rst-toc)
(rst-uncomment-region, rst-font-lock-extend-region-internal):
* lisp/thumbs.el (thumbs-mode):
* lisp/vc/ediff-util.el (ediff-restore-diff):
* lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag):
* lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p):
* lisp/wid-edit.el (widget-field-value-set, string):
* lisp/x-dnd.el (x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
|
|
|
|
interactively), move out of enclosing strings as well. If
|
2014-04-09 16:58:08 +00:00
|
|
|
|
NO-SYNTAX-CROSSING is non-nil (as it is interactively), prefer to
|
|
|
|
|
break out of any enclosing string instead of moving to the start
|
|
|
|
|
of a list broken across multiple strings. On error, location of
|
|
|
|
|
point is unspecified."
|
|
|
|
|
(interactive "^p\nd\nd")
|
2000-08-20 18:12:07 +00:00
|
|
|
|
(or arg (setq arg 1))
|
2010-09-20 21:45:09 +00:00
|
|
|
|
(let ((inc (if (> arg 0) 1 -1))
|
2014-04-09 16:58:08 +00:00
|
|
|
|
(pos nil))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(while (/= arg 0)
|
2014-04-09 16:58:08 +00:00
|
|
|
|
(condition-case err
|
|
|
|
|
(save-restriction
|
|
|
|
|
;; If we've been asked not to cross string boundaries
|
|
|
|
|
;; and we're inside a string, narrow to that string so
|
|
|
|
|
;; that scan-lists doesn't find a match in a different
|
|
|
|
|
;; string.
|
|
|
|
|
(when no-syntax-crossing
|
|
|
|
|
(let* ((syntax (syntax-ppss))
|
|
|
|
|
(string-comment-start (nth 8 syntax)))
|
|
|
|
|
(when string-comment-start
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char string-comment-start)
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(point)
|
|
|
|
|
(if (nth 3 syntax) ; in string
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn (forward-sexp) (point))
|
|
|
|
|
(scan-error (point-max)))
|
|
|
|
|
(forward-comment 1)
|
|
|
|
|
(point)))))))
|
|
|
|
|
(if (null forward-sexp-function)
|
|
|
|
|
(goto-char (or (scan-lists (point) inc 1)
|
|
|
|
|
(buffer-end arg)))
|
|
|
|
|
(condition-case err
|
|
|
|
|
(while (progn (setq pos (point))
|
|
|
|
|
(forward-sexp inc)
|
|
|
|
|
(/= (point) pos)))
|
|
|
|
|
(scan-error (goto-char (nth (if (> arg 0) 3 2) err))))
|
|
|
|
|
(if (= (point) pos)
|
|
|
|
|
(signal 'scan-error
|
|
|
|
|
(list "Unbalanced parentheses" (point) (point))))))
|
|
|
|
|
(scan-error
|
|
|
|
|
(let ((syntax nil))
|
|
|
|
|
(or
|
|
|
|
|
;; If we bumped up against the end of a list, see whether
|
|
|
|
|
;; we're inside a string: if so, just go to the beginning
|
|
|
|
|
;; or end of that string.
|
|
|
|
|
(and escape-strings
|
|
|
|
|
(or syntax (setf syntax (syntax-ppss)))
|
|
|
|
|
(nth 3 syntax)
|
|
|
|
|
(goto-char (nth 8 syntax))
|
|
|
|
|
(progn (when (> inc 0)
|
|
|
|
|
(forward-sexp))
|
|
|
|
|
t))
|
|
|
|
|
;; If we narrowed to a comment above and failed to escape
|
|
|
|
|
;; it, the error might be our fault, not an indication
|
|
|
|
|
;; that we're out of syntax. Try again from beginning or
|
|
|
|
|
;; end of the comment.
|
|
|
|
|
(and no-syntax-crossing
|
|
|
|
|
(or syntax (setf syntax (syntax-ppss)))
|
|
|
|
|
(nth 4 syntax)
|
|
|
|
|
(goto-char (nth 8 syntax))
|
|
|
|
|
(or (< inc 0)
|
|
|
|
|
(forward-comment 1))
|
|
|
|
|
(setf arg (+ arg inc)))
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(if no-syntax-crossing
|
|
|
|
|
;; Assume called interactively; don't signal an error.
|
|
|
|
|
(user-error "At top level")
|
|
|
|
|
(signal (car err) (cdr err)))))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(setq arg (- arg inc)))))
|
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun kill-sexp (&optional arg interactive)
|
2005-01-17 23:48:10 +00:00
|
|
|
|
"Kill the sexp (balanced expression) following point.
|
|
|
|
|
With ARG, kill that many sexps after point.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
Negative arg -N means kill N sexps before point.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "p\nd")
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(if interactive
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(condition-case _
|
|
|
|
|
(kill-sexp arg nil)
|
|
|
|
|
(scan-error (user-error (if (> arg 0)
|
|
|
|
|
"No next sexp"
|
|
|
|
|
"No previous sexp"))))
|
|
|
|
|
(let ((opoint (point)))
|
|
|
|
|
(forward-sexp (or arg 1))
|
|
|
|
|
(kill-region opoint (point)))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(defun backward-kill-sexp (&optional arg interactive)
|
2005-01-17 23:48:10 +00:00
|
|
|
|
"Kill the sexp (balanced expression) preceding point.
|
|
|
|
|
With ARG, kill that many sexps before point.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
Negative arg -N means kill N sexps after point.
|
2020-09-18 10:49:33 +00:00
|
|
|
|
This command assumes point is not in a string or comment.
|
2020-09-23 16:08:32 +00:00
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
2020-09-18 10:49:33 +00:00
|
|
|
|
(interactive "p\nd")
|
2020-09-23 16:08:32 +00:00
|
|
|
|
(kill-sexp (- (or arg 1)) interactive))
|
2004-09-04 12:56:54 +00:00
|
|
|
|
|
|
|
|
|
;; After Zmacs:
|
|
|
|
|
(defun kill-backward-up-list (&optional arg)
|
|
|
|
|
"Kill the form containing the current sexp, leaving the sexp itself.
|
|
|
|
|
A prefix argument ARG causes the relevant number of surrounding
|
2008-11-26 10:30:53 +00:00
|
|
|
|
forms to be removed.
|
|
|
|
|
This command assumes point is not in a string or comment."
|
2004-09-04 12:56:54 +00:00
|
|
|
|
(interactive "*p")
|
|
|
|
|
(let ((current-sexp (thing-at-point 'sexp)))
|
|
|
|
|
(if current-sexp
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-up-list arg)
|
|
|
|
|
(kill-sexp)
|
|
|
|
|
(insert current-sexp))
|
2015-02-18 07:35:49 +00:00
|
|
|
|
(user-error "Not at a sexp"))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2000-01-21 02:44:44 +00:00
|
|
|
|
(defvar beginning-of-defun-function nil
|
2000-01-05 15:08:36 +00:00
|
|
|
|
"If non-nil, function for `beginning-of-defun-raw' to call.
|
|
|
|
|
This is used to find the beginning of the defun instead of using the
|
2000-01-21 02:44:44 +00:00
|
|
|
|
normal recipe (see `beginning-of-defun'). Major modes can define this
|
|
|
|
|
if defining `defun-prompt-regexp' is not sufficient to handle the mode's
|
|
|
|
|
needs.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
|
2007-11-22 22:12:22 +00:00
|
|
|
|
The function takes the same argument as `beginning-of-defun' and should
|
|
|
|
|
behave similarly, returning non-nil if it found the beginning of a defun.
|
|
|
|
|
Ideally it should move to a point right before an open-paren which encloses
|
|
|
|
|
the body of the defun.")
|
2000-01-05 15:08:36 +00:00
|
|
|
|
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(defun beginning-of-defun (&optional arg)
|
|
|
|
|
"Move backward to the beginning of a defun.
|
2008-08-11 21:38:17 +00:00
|
|
|
|
With ARG, do it that many times. Negative ARG means move forward
|
|
|
|
|
to the ARGth following beginning of defun.
|
|
|
|
|
|
|
|
|
|
If search is successful, return t; point ends up at the beginning
|
|
|
|
|
of the line where the search succeeded. Otherwise, return nil.
|
|
|
|
|
|
|
|
|
|
When `open-paren-in-column-0-is-defun-start' is non-nil, a defun
|
|
|
|
|
is assumed to start where there is a char with open-parenthesis
|
|
|
|
|
syntax at the beginning of a line. If `defun-prompt-regexp' is
|
|
|
|
|
non-nil, then a string which matches that regexp may also precede
|
|
|
|
|
the open-parenthesis. If `defun-prompt-regexp' and
|
|
|
|
|
`open-paren-in-column-0-is-defun-start' are both nil, this
|
|
|
|
|
function instead finds an open-paren at the outermost level.
|
|
|
|
|
|
|
|
|
|
If the variable `beginning-of-defun-function' is non-nil, its
|
|
|
|
|
value is called as a function, with argument ARG, to find the
|
|
|
|
|
defun's beginning.
|
|
|
|
|
|
|
|
|
|
Regardless of the values of `defun-prompt-regexp' and
|
|
|
|
|
`beginning-of-defun-function', point always moves to the
|
|
|
|
|
beginning of the line whenever the search is successful."
|
2009-02-04 05:48:16 +00:00
|
|
|
|
(interactive "^p")
|
2004-12-14 12:18:11 +00:00
|
|
|
|
(or (not (eq this-command 'beginning-of-defun))
|
2004-12-13 03:09:59 +00:00
|
|
|
|
(eq last-command 'beginning-of-defun)
|
|
|
|
|
(and transient-mark-mode mark-active)
|
|
|
|
|
(push-mark))
|
1994-03-18 02:21:52 +00:00
|
|
|
|
(and (beginning-of-defun-raw arg)
|
|
|
|
|
(progn (beginning-of-line) t)))
|
|
|
|
|
|
|
|
|
|
(defun beginning-of-defun-raw (&optional arg)
|
|
|
|
|
"Move point to the character that starts a defun.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
This is identical to function `beginning-of-defun', except that point
|
|
|
|
|
does not move to the beginning of the line when `defun-prompt-regexp'
|
|
|
|
|
is non-nil.
|
|
|
|
|
|
2000-01-21 02:44:44 +00:00
|
|
|
|
If variable `beginning-of-defun-function' is non-nil, its value
|
|
|
|
|
is called as a function to find the defun's beginning."
|
2009-02-04 05:48:16 +00:00
|
|
|
|
(interactive "^p") ; change this to "P", maybe, if we ever come to pass ARG
|
2006-12-17 22:56:39 +00:00
|
|
|
|
; to beginning-of-defun-function.
|
|
|
|
|
(unless arg (setq arg 1))
|
2006-11-08 19:22:33 +00:00
|
|
|
|
(cond
|
|
|
|
|
(beginning-of-defun-function
|
2007-11-22 22:12:22 +00:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(funcall beginning-of-defun-function arg)
|
|
|
|
|
;; We used to define beginning-of-defun-function as taking no argument
|
|
|
|
|
;; but that makes it impossible to implement correct forward motion:
|
|
|
|
|
;; we used to use end-of-defun for that, but it's not supposed to do
|
|
|
|
|
;; the same thing (it moves to the end of a defun not to the beginning
|
|
|
|
|
;; of the next).
|
|
|
|
|
;; In case the beginning-of-defun-function uses the old calling
|
|
|
|
|
;; convention, fallback on the old implementation.
|
|
|
|
|
(wrong-number-of-arguments
|
|
|
|
|
(if (> arg 0)
|
2013-06-03 15:40:35 +00:00
|
|
|
|
(dotimes (_ arg)
|
2007-11-22 22:12:22 +00:00
|
|
|
|
(funcall beginning-of-defun-function))
|
2013-06-03 15:40:35 +00:00
|
|
|
|
(dotimes (_ (- arg))
|
2012-02-23 08:13:48 +00:00
|
|
|
|
(funcall end-of-defun-function))))))
|
2006-11-08 19:22:33 +00:00
|
|
|
|
|
|
|
|
|
((or defun-prompt-regexp open-paren-in-column-0-is-defun-start)
|
|
|
|
|
(and (< arg 0) (not (eobp)) (forward-char 1))
|
2017-12-13 19:13:11 +00:00
|
|
|
|
(and (let (found)
|
|
|
|
|
(while
|
|
|
|
|
(and (setq found
|
|
|
|
|
(re-search-backward
|
|
|
|
|
(if defun-prompt-regexp
|
|
|
|
|
(concat (if open-paren-in-column-0-is-defun-start
|
|
|
|
|
"^\\s(\\|" "")
|
|
|
|
|
"\\(?:" defun-prompt-regexp "\\)\\s(")
|
|
|
|
|
"^\\s(")
|
|
|
|
|
nil 'move arg))
|
|
|
|
|
(nth 8 (syntax-ppss))))
|
|
|
|
|
found)
|
2009-02-19 17:31:51 +00:00
|
|
|
|
(progn (goto-char (1- (match-end 0)))
|
|
|
|
|
t)))
|
2006-11-08 19:22:33 +00:00
|
|
|
|
|
2006-12-17 22:56:39 +00:00
|
|
|
|
;; If open-paren-in-column-0-is-defun-start and defun-prompt-regexp
|
|
|
|
|
;; are both nil, column 0 has no significance - so scan forward
|
|
|
|
|
;; from BOB to see how nested point is, then carry on from there.
|
|
|
|
|
;;
|
|
|
|
|
;; It is generally not a good idea to land up here, because the
|
|
|
|
|
;; call to scan-lists below can be extremely slow. This is because
|
|
|
|
|
;; back_comment in syntax.c may have to scan from bob to find the
|
|
|
|
|
;; beginning of each comment. Fixing this is not trivial -- cyd.
|
|
|
|
|
|
|
|
|
|
((eq arg 0))
|
2006-11-08 19:22:33 +00:00
|
|
|
|
(t
|
2006-12-17 22:56:39 +00:00
|
|
|
|
(let ((floor (point-min))
|
|
|
|
|
(ceiling (point-max))
|
|
|
|
|
(arg-+ve (> arg 0)))
|
2006-11-08 19:22:33 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
2019-06-12 15:45:59 +00:00
|
|
|
|
(let ((ppss (with-suppressed-warnings ((obsolete syntax-begin-function))
|
|
|
|
|
(let (syntax-begin-function)
|
|
|
|
|
(syntax-ppss))))
|
2006-12-17 22:56:39 +00:00
|
|
|
|
;; position of least enclosing paren, or nil.
|
|
|
|
|
encl-pos)
|
|
|
|
|
;; Back out of any comment/string, so that encl-pos will always
|
|
|
|
|
;; become nil if we're at top-level.
|
|
|
|
|
(when (nth 8 ppss)
|
|
|
|
|
(goto-char (nth 8 ppss))
|
|
|
|
|
(setq ppss (syntax-ppss))) ; should be fast, due to cache.
|
|
|
|
|
(setq encl-pos (syntax-ppss-toplevel-pos ppss))
|
|
|
|
|
(if encl-pos (goto-char encl-pos))
|
|
|
|
|
|
|
|
|
|
(and encl-pos arg-+ve (setq arg (1- arg)))
|
|
|
|
|
(and (not encl-pos) (not arg-+ve) (not (looking-at "\\s("))
|
|
|
|
|
(setq arg (1+ arg)))
|
|
|
|
|
|
|
|
|
|
(condition-case nil ; to catch crazy parens.
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (scan-lists (point) (- arg) 0))
|
|
|
|
|
(if arg-+ve
|
|
|
|
|
(if (>= (point) floor)
|
|
|
|
|
t
|
|
|
|
|
(goto-char floor)
|
|
|
|
|
nil)
|
|
|
|
|
;; forward to next (, or trigger the c-c
|
|
|
|
|
(goto-char (1- (scan-lists (point) 1 -1)))
|
|
|
|
|
(if (<= (point) ceiling)
|
|
|
|
|
t
|
|
|
|
|
(goto-char ceiling)
|
|
|
|
|
nil)))
|
|
|
|
|
(error
|
|
|
|
|
(goto-char (if arg-+ve floor ceiling))
|
|
|
|
|
nil))))))))
|
2000-01-05 15:08:36 +00:00
|
|
|
|
|
2017-03-31 11:06:06 +00:00
|
|
|
|
(defun beginning-of-defun--in-emptyish-line-p ()
|
|
|
|
|
"Return non-nil if the point is in an \"emptyish\" line.
|
|
|
|
|
This means a line that consists entirely of comments and/or
|
|
|
|
|
whitespace."
|
2017-11-26 06:45:41 +00:00
|
|
|
|
;; See https://lists.gnu.org/r/help-gnu-emacs/2016-08/msg00141.html
|
2017-03-31 11:06:06 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line 0)
|
2018-01-06 11:48:32 +00:00
|
|
|
|
(let ((ppss (syntax-ppss)))
|
|
|
|
|
(and (null (nth 3 ppss))
|
|
|
|
|
(< (line-end-position)
|
|
|
|
|
(progn (when (nth 4 ppss)
|
|
|
|
|
(goto-char (nth 8 ppss)))
|
|
|
|
|
(forward-comment (point-max))
|
|
|
|
|
(point)))))))
|
2017-03-31 11:06:06 +00:00
|
|
|
|
|
|
|
|
|
(defun beginning-of-defun-comments (&optional arg)
|
|
|
|
|
"Move to the beginning of ARGth defun, including comments."
|
|
|
|
|
(interactive "^p")
|
|
|
|
|
(unless arg (setq arg 1))
|
|
|
|
|
(beginning-of-defun arg)
|
2017-05-09 07:38:49 +00:00
|
|
|
|
(let (first-line-p)
|
|
|
|
|
(while (let ((ppss (progn (setq first-line-p (= (forward-line -1) -1))
|
|
|
|
|
(syntax-ppss (line-end-position)))))
|
|
|
|
|
(while (and (nth 4 ppss) ; If eol is in a line-spanning comment,
|
|
|
|
|
(< (nth 8 ppss) (line-beginning-position)))
|
|
|
|
|
(goto-char (nth 8 ppss)) ; skip to comment start.
|
|
|
|
|
(setq ppss (syntax-ppss (line-end-position))))
|
|
|
|
|
(and (not first-line-p)
|
|
|
|
|
(progn (skip-syntax-backward
|
|
|
|
|
"-" (line-beginning-position))
|
|
|
|
|
(not (bolp))) ; Check for blank line.
|
2018-01-06 11:48:32 +00:00
|
|
|
|
(beginning-of-defun--in-emptyish-line-p)))) ; Check for non-comment text.
|
2017-05-09 07:38:49 +00:00
|
|
|
|
(forward-line (if first-line-p 0 1))))
|
2017-03-31 11:06:06 +00:00
|
|
|
|
|
2009-03-03 16:12:02 +00:00
|
|
|
|
(defvar end-of-defun-function
|
|
|
|
|
(lambda () (forward-sexp 1))
|
2007-11-26 20:27:12 +00:00
|
|
|
|
"Function for `end-of-defun' to call.
|
2009-02-14 04:19:34 +00:00
|
|
|
|
This is used to find the end of the defun at point.
|
2007-11-26 20:27:12 +00:00
|
|
|
|
It is called with no argument, right after calling `beginning-of-defun-raw'.
|
2009-02-14 04:19:34 +00:00
|
|
|
|
So the function can assume that point is at the beginning of the defun body.
|
|
|
|
|
It should move point to the first position after the defun.")
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
|
|
|
|
(defun buffer-end (arg)
|
2005-04-08 23:10:24 +00:00
|
|
|
|
"Return the \"far end\" position of the buffer, in direction ARG.
|
2005-02-06 10:40:20 +00:00
|
|
|
|
If ARG is positive, that's the end of the buffer.
|
|
|
|
|
Otherwise, that's the beginning of the buffer."
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(if (> arg 0) (point-max) (point-min)))
|
|
|
|
|
|
2021-04-30 15:09:21 +00:00
|
|
|
|
(defun end-of-defun (&optional arg interactive)
|
2005-04-08 23:10:24 +00:00
|
|
|
|
"Move forward to next end of defun.
|
|
|
|
|
With argument, do it that many times.
|
1990-08-27 04:15:41 +00:00
|
|
|
|
Negative argument -N means move back to Nth preceding end of defun.
|
|
|
|
|
|
2000-01-05 15:08:36 +00:00
|
|
|
|
An end of a defun occurs right after the close-parenthesis that
|
|
|
|
|
matches the open-parenthesis that starts a defun; see function
|
2000-01-21 02:44:44 +00:00
|
|
|
|
`beginning-of-defun'.
|
|
|
|
|
|
|
|
|
|
If variable `end-of-defun-function' is non-nil, its value
|
2021-04-30 15:09:21 +00:00
|
|
|
|
is called as a function to find the defun's end.
|
|
|
|
|
|
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
|
|
|
|
(interactive "^p\nd")
|
|
|
|
|
(if interactive
|
|
|
|
|
(condition-case e
|
|
|
|
|
(end-of-defun arg nil)
|
|
|
|
|
(scan-error (user-error (cadr e))))
|
|
|
|
|
(or (not (eq this-command 'end-of-defun))
|
|
|
|
|
(eq last-command 'end-of-defun)
|
|
|
|
|
(and transient-mark-mode mark-active)
|
|
|
|
|
(push-mark))
|
|
|
|
|
(if (or (null arg) (= arg 0)) (setq arg 1))
|
|
|
|
|
(let ((pos (point))
|
|
|
|
|
(beg (progn (end-of-line 1) (beginning-of-defun-raw 1) (point)))
|
|
|
|
|
(skip (lambda ()
|
|
|
|
|
;; When comparing point against pos, we want to consider that
|
|
|
|
|
;; if point was right after the end of the function, it's
|
|
|
|
|
;; still considered as "in that function".
|
|
|
|
|
;; E.g. `eval-defun' from right after the last close-paren.
|
|
|
|
|
(unless (bolp)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(if (looking-at "\\s<\\|\n")
|
|
|
|
|
(forward-line 1))))))
|
|
|
|
|
(funcall end-of-defun-function)
|
|
|
|
|
(when (<= arg 1)
|
|
|
|
|
(funcall skip))
|
|
|
|
|
(cond
|
|
|
|
|
((> arg 0)
|
|
|
|
|
;; Moving forward.
|
|
|
|
|
(if (> (point) pos)
|
|
|
|
|
;; We already moved forward by one because we started from
|
|
|
|
|
;; within a function.
|
|
|
|
|
(setq arg (1- arg))
|
|
|
|
|
;; We started from after the end of the previous function.
|
|
|
|
|
(goto-char pos))
|
|
|
|
|
(unless (zerop arg)
|
|
|
|
|
(beginning-of-defun-raw (- arg))
|
|
|
|
|
(funcall end-of-defun-function)))
|
|
|
|
|
((< arg 0)
|
|
|
|
|
;; Moving backward.
|
|
|
|
|
(if (< (point) pos)
|
|
|
|
|
;; We already moved backward because we started from between
|
|
|
|
|
;; two functions.
|
|
|
|
|
(setq arg (1+ arg))
|
|
|
|
|
;; We started from inside a function.
|
|
|
|
|
(goto-char beg))
|
|
|
|
|
(unless (zerop arg)
|
|
|
|
|
(beginning-of-defun-raw (- arg))
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(funcall end-of-defun-function))))
|
|
|
|
|
(funcall skip)
|
|
|
|
|
(while (and (< arg 0) (>= (point) pos))
|
|
|
|
|
;; We intended to move backward, but this ended up not doing so:
|
|
|
|
|
;; Try harder!
|
|
|
|
|
(goto-char beg)
|
2009-02-12 04:31:01 +00:00
|
|
|
|
(beginning-of-defun-raw (- arg))
|
2021-04-30 15:09:21 +00:00
|
|
|
|
(if (>= (point) beg)
|
|
|
|
|
(setq arg 0)
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(funcall end-of-defun-function)
|
|
|
|
|
(funcall skip))))))
|
|
|
|
|
|
|
|
|
|
(defun mark-defun (&optional arg interactive)
|
1990-08-27 04:15:41 +00:00
|
|
|
|
"Put mark at end of this defun, point at beginning.
|
2002-02-15 08:53:15 +00:00
|
|
|
|
The defun marked is the one that contains point or follows point.
|
2017-03-31 11:06:06 +00:00
|
|
|
|
With positive ARG, mark this and that many next defuns; with negative
|
|
|
|
|
ARG, change the direction of marking.
|
2004-12-29 01:32:06 +00:00
|
|
|
|
|
2017-03-31 11:06:06 +00:00
|
|
|
|
If the mark is active, it marks the next or previous defun(s) after
|
2021-04-30 15:09:21 +00:00
|
|
|
|
the one(s) already marked.
|
|
|
|
|
|
|
|
|
|
If INTERACTIVE is non-nil, as it is interactively,
|
|
|
|
|
report errors as appropriate for this kind of usage."
|
|
|
|
|
(interactive "p\nd")
|
|
|
|
|
(if interactive
|
|
|
|
|
(condition-case e
|
|
|
|
|
(mark-defun arg nil)
|
|
|
|
|
(scan-error (user-error (cadr e))))
|
|
|
|
|
(setq arg (or arg 1))
|
|
|
|
|
;; There is no `mark-defun-back' function - see
|
|
|
|
|
;; https://lists.gnu.org/r/bug-gnu-emacs/2016-11/msg00079.html
|
|
|
|
|
;; for explanation
|
|
|
|
|
(when (eq last-command 'mark-defun-back)
|
|
|
|
|
(setq arg (- arg)))
|
|
|
|
|
(when (< arg 0)
|
|
|
|
|
(setq this-command 'mark-defun-back))
|
|
|
|
|
(cond ((use-region-p)
|
|
|
|
|
(if (>= arg 0)
|
|
|
|
|
(set-mark
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (mark))
|
|
|
|
|
;; change the dotimes below to (end-of-defun arg)
|
|
|
|
|
;; once bug #24427 is fixed
|
2017-03-31 11:06:06 +00:00
|
|
|
|
(dotimes (_ignore arg)
|
|
|
|
|
(end-of-defun))
|
2021-04-30 15:09:21 +00:00
|
|
|
|
(point)))
|
|
|
|
|
(beginning-of-defun-comments (- arg))))
|
|
|
|
|
(t
|
|
|
|
|
(let ((opoint (point))
|
|
|
|
|
beg end)
|
|
|
|
|
(push-mark opoint)
|
|
|
|
|
;; Try first in this order for the sake of languages with nested
|
|
|
|
|
;; functions where several can end at the same place as with the
|
|
|
|
|
;; offside rule, e.g. Python.
|
|
|
|
|
(beginning-of-defun-comments)
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(end-of-defun)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(when (or (and (<= (point) opoint)
|
|
|
|
|
(> arg 0))
|
|
|
|
|
(= beg (point-min))) ; we were before the first defun!
|
|
|
|
|
;; beginning-of-defun moved back one defun so we got the wrong
|
|
|
|
|
;; one. If ARG < 0, however, we actually want to go back.
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
(end-of-defun)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(beginning-of-defun-comments)
|
|
|
|
|
(setq beg (point)))
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(cond ((> arg 0)
|
|
|
|
|
;; change the dotimes below to (end-of-defun arg)
|
|
|
|
|
;; once bug #24427 is fixed
|
|
|
|
|
(dotimes (_ignore arg)
|
|
|
|
|
(end-of-defun))
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(push-mark end nil t)
|
|
|
|
|
(goto-char beg))
|
|
|
|
|
(t
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(unless (= arg -1)
|
|
|
|
|
;; beginning-of-defun behaves strange with zero arg - see
|
|
|
|
|
;; lists.gnu.org/r/bug-gnu-emacs/2017-02/msg00196.html
|
|
|
|
|
(beginning-of-defun (1- (- arg))))
|
|
|
|
|
(push-mark end nil t))))))
|
|
|
|
|
(skip-chars-backward "[:space:]\n")
|
|
|
|
|
(unless (bobp)
|
|
|
|
|
(forward-line 1))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2014-07-04 02:00:54 +00:00
|
|
|
|
(defvar narrow-to-defun-include-comments nil
|
|
|
|
|
"If non-nil, `narrow-to-defun' will also show comments preceding the defun.")
|
|
|
|
|
|
|
|
|
|
(defun narrow-to-defun (&optional include-comments)
|
1996-08-29 04:42:40 +00:00
|
|
|
|
"Make text outside current defun invisible.
|
2014-07-04 02:00:54 +00:00
|
|
|
|
The current defun is the one that contains point or follows point.
|
|
|
|
|
Preceding comments are included if INCLUDE-COMMENTS is non-nil.
|
|
|
|
|
Interactively, the behavior depends on `narrow-to-defun-include-comments'."
|
|
|
|
|
(interactive (list narrow-to-defun-include-comments))
|
1996-08-29 04:42:40 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(widen)
|
2004-05-22 07:41:55 +00:00
|
|
|
|
(let ((opoint (point))
|
|
|
|
|
beg end)
|
|
|
|
|
;; Try first in this order for the sake of languages with nested
|
|
|
|
|
;; functions where several can end at the same place as with
|
|
|
|
|
;; the offside rule, e.g. Python.
|
2012-04-11 02:12:20 +00:00
|
|
|
|
|
|
|
|
|
;; Finding the start of the function is a bit problematic since
|
|
|
|
|
;; `beginning-of-defun' when we are on the first character of
|
|
|
|
|
;; the function might go to the previous function.
|
|
|
|
|
;;
|
|
|
|
|
;; Therefore we first move one character forward and then call
|
|
|
|
|
;; `beginning-of-defun'. However now we must check that we did
|
|
|
|
|
;; not move into the next function.
|
|
|
|
|
(let ((here (point)))
|
|
|
|
|
(unless (eolp)
|
|
|
|
|
(forward-char))
|
|
|
|
|
(beginning-of-defun)
|
|
|
|
|
(when (< (point) here)
|
|
|
|
|
(goto-char here)
|
|
|
|
|
(beginning-of-defun)))
|
2004-05-22 07:41:55 +00:00
|
|
|
|
(setq beg (point))
|
2004-01-29 17:56:42 +00:00
|
|
|
|
(end-of-defun)
|
2004-05-22 07:41:55 +00:00
|
|
|
|
(setq end (point))
|
|
|
|
|
(while (looking-at "^\n")
|
|
|
|
|
(forward-line 1))
|
|
|
|
|
(unless (> (point) opoint)
|
|
|
|
|
;; beginning-of-defun moved back one defun
|
|
|
|
|
;; so we got the wrong one.
|
|
|
|
|
(goto-char opoint)
|
|
|
|
|
(end-of-defun)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(beginning-of-defun)
|
|
|
|
|
(setq beg (point)))
|
2014-07-04 02:00:54 +00:00
|
|
|
|
(when include-comments
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
;; Move back past all preceding comments (and whitespace).
|
|
|
|
|
(when (forward-comment -1)
|
|
|
|
|
(while (forward-comment -1))
|
|
|
|
|
;; Move forwards past any page breaks within these comments.
|
|
|
|
|
(when (and page-delimiter (not (string= page-delimiter "")))
|
|
|
|
|
(while (re-search-forward page-delimiter beg t)))
|
|
|
|
|
;; Lastly, move past any empty lines.
|
|
|
|
|
(skip-chars-forward "[:space:]\n")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq beg (point))))
|
2004-05-22 07:41:55 +00:00
|
|
|
|
(goto-char end)
|
|
|
|
|
(re-search-backward "^\n" (- (point) 1) t)
|
|
|
|
|
(narrow-to-region beg end))))
|
1996-08-29 04:42:40 +00:00
|
|
|
|
|
2019-05-06 19:32:26 +00:00
|
|
|
|
(defcustom insert-pair-alist
|
|
|
|
|
'((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\'))
|
2004-05-28 21:12:25 +00:00
|
|
|
|
"Alist of paired characters inserted by `insert-pair'.
|
|
|
|
|
Each element looks like (OPEN-CHAR CLOSE-CHAR) or (COMMAND-CHAR
|
|
|
|
|
OPEN-CHAR CLOSE-CHAR). The characters OPEN-CHAR and CLOSE-CHAR
|
|
|
|
|
of the pair whose key is equal to the last input character with
|
2016-04-30 14:28:52 +00:00
|
|
|
|
or without modifiers, are inserted by `insert-pair'.
|
|
|
|
|
|
|
|
|
|
If COMMAND-CHAR is specified, it is a character that triggers the
|
|
|
|
|
insertion of the open/close pair, and COMMAND-CHAR itself isn't
|
2019-05-06 19:32:26 +00:00
|
|
|
|
inserted."
|
|
|
|
|
:type '(repeat (choice (list :tag "Pair"
|
|
|
|
|
(character :tag "Open")
|
|
|
|
|
(character :tag "Close"))
|
|
|
|
|
(list :tag "Triple"
|
|
|
|
|
(character :tag "Command")
|
|
|
|
|
(character :tag "Open")
|
|
|
|
|
(character :tag "Close"))))
|
|
|
|
|
:group 'lisp
|
|
|
|
|
:version "27.1")
|
2004-05-28 21:12:25 +00:00
|
|
|
|
|
|
|
|
|
(defun insert-pair (&optional arg open close)
|
2004-05-01 03:58:43 +00:00
|
|
|
|
"Enclose following ARG sexps in a pair of OPEN and CLOSE characters.
|
|
|
|
|
Leave point after the first character.
|
1996-10-08 23:13:39 +00:00
|
|
|
|
A negative ARG encloses the preceding ARG sexps instead.
|
2004-05-01 03:58:43 +00:00
|
|
|
|
No argument is equivalent to zero: just insert characters
|
|
|
|
|
and leave point between.
|
1994-02-07 22:57:35 +00:00
|
|
|
|
If `parens-require-spaces' is non-nil, this command also inserts a space
|
2004-05-01 03:58:43 +00:00
|
|
|
|
before and after, depending on the surrounding characters.
|
2004-05-28 21:12:25 +00:00
|
|
|
|
If region is active, insert enclosing characters at region boundaries.
|
|
|
|
|
|
|
|
|
|
If arguments OPEN and CLOSE are nil, the character pair is found
|
|
|
|
|
from the variable `insert-pair-alist' according to the last input
|
|
|
|
|
character with or without modifiers. If no character pair is
|
|
|
|
|
found in the variable `insert-pair-alist', then the last input
|
2008-11-26 10:30:53 +00:00
|
|
|
|
character is inserted ARG times.
|
|
|
|
|
|
|
|
|
|
This command assumes point is not in a string or comment."
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(interactive "P")
|
2004-05-28 21:12:25 +00:00
|
|
|
|
(if (not (and open close))
|
2009-01-09 04:29:16 +00:00
|
|
|
|
(let ((pair (or (assq last-command-event insert-pair-alist)
|
2004-05-28 21:12:25 +00:00
|
|
|
|
(assq (event-basic-type last-command-event)
|
|
|
|
|
insert-pair-alist))))
|
|
|
|
|
(if pair
|
|
|
|
|
(if (nth 2 pair)
|
|
|
|
|
(setq open (nth 1 pair) close (nth 2 pair))
|
|
|
|
|
(setq open (nth 0 pair) close (nth 1 pair))))))
|
|
|
|
|
(if (and open close)
|
|
|
|
|
(if (and transient-mark-mode mark-active)
|
|
|
|
|
(progn
|
2016-02-24 02:54:17 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (region-end))
|
|
|
|
|
(insert close))
|
2016-02-24 02:55:29 +00:00
|
|
|
|
(goto-char (region-beginning))
|
|
|
|
|
(insert open))
|
2004-05-28 21:12:25 +00:00
|
|
|
|
(if arg (setq arg (prefix-numeric-value arg))
|
|
|
|
|
(setq arg 0))
|
|
|
|
|
(cond ((> arg 0) (skip-chars-forward " \t"))
|
|
|
|
|
((< arg 0) (forward-sexp arg) (setq arg (- arg))))
|
|
|
|
|
(and parens-require-spaces
|
|
|
|
|
(not (bobp))
|
|
|
|
|
(memq (char-syntax (preceding-char)) (list ?w ?_ (char-syntax close)))
|
|
|
|
|
(insert " "))
|
|
|
|
|
(insert open)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(or (eq arg 0) (forward-sexp arg))
|
|
|
|
|
(insert close)
|
|
|
|
|
(and parens-require-spaces
|
|
|
|
|
(not (eobp))
|
|
|
|
|
(memq (char-syntax (following-char)) (list ?w ?_ (char-syntax open)))
|
|
|
|
|
(insert " "))))
|
|
|
|
|
(insert-char (event-basic-type last-command-event)
|
|
|
|
|
(prefix-numeric-value arg))))
|
|
|
|
|
|
|
|
|
|
(defun insert-parentheses (&optional arg)
|
2005-04-08 23:10:24 +00:00
|
|
|
|
"Enclose following ARG sexps in parentheses.
|
|
|
|
|
Leave point after open-paren.
|
2004-05-01 03:58:43 +00:00
|
|
|
|
A negative ARG encloses the preceding ARG sexps instead.
|
|
|
|
|
No argument is equivalent to zero: just insert `()' and leave point between.
|
|
|
|
|
If `parens-require-spaces' is non-nil, this command also inserts a space
|
|
|
|
|
before and after, depending on the surrounding characters.
|
2008-11-26 10:30:53 +00:00
|
|
|
|
If region is active, insert enclosing characters at region boundaries.
|
|
|
|
|
|
|
|
|
|
This command assumes point is not in a string or comment."
|
2004-05-01 03:58:43 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(insert-pair arg ?\( ?\)))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2020-11-15 20:32:39 +00:00
|
|
|
|
(defcustom delete-pair-blink-delay blink-matching-delay
|
|
|
|
|
"Time in seconds to delay after showing a paired character to delete.
|
|
|
|
|
It's used by the command `delete-pair'. The value 0 disables blinking."
|
|
|
|
|
:type 'number
|
|
|
|
|
:group 'lisp
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2018-10-18 23:09:15 +00:00
|
|
|
|
(defun delete-pair (&optional arg)
|
2020-09-22 14:44:15 +00:00
|
|
|
|
"Delete a pair of characters enclosing ARG sexps that follow point.
|
2020-11-15 20:32:39 +00:00
|
|
|
|
A negative ARG deletes a pair around the preceding ARG sexps instead.
|
|
|
|
|
The option `delete-pair-blink-delay' can disable blinking."
|
2020-09-22 14:44:15 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(if arg
|
|
|
|
|
(setq arg (prefix-numeric-value arg))
|
|
|
|
|
(setq arg 1))
|
|
|
|
|
(if (< arg 0)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((close-char (char-before)))
|
|
|
|
|
(forward-sexp arg)
|
|
|
|
|
(unless (member (list (char-after) close-char)
|
|
|
|
|
(mapcar (lambda (p)
|
|
|
|
|
(if (= (length p) 3) (cdr p) p))
|
|
|
|
|
insert-pair-alist))
|
|
|
|
|
(error "Not after matching pair"))
|
2020-11-15 20:32:39 +00:00
|
|
|
|
(when (and (numberp delete-pair-blink-delay)
|
|
|
|
|
(> delete-pair-blink-delay 0))
|
|
|
|
|
(sit-for delete-pair-blink-delay))
|
2020-09-22 14:44:15 +00:00
|
|
|
|
(delete-char 1)))
|
|
|
|
|
(delete-char -1))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((open-char (char-after)))
|
|
|
|
|
(forward-sexp arg)
|
|
|
|
|
(unless (member (list open-char (char-before))
|
|
|
|
|
(mapcar (lambda (p)
|
|
|
|
|
(if (= (length p) 3) (cdr p) p))
|
|
|
|
|
insert-pair-alist))
|
|
|
|
|
(error "Not before matching pair"))
|
2020-11-15 20:32:39 +00:00
|
|
|
|
(when (and (numberp delete-pair-blink-delay)
|
|
|
|
|
(> delete-pair-blink-delay 0))
|
|
|
|
|
(sit-for delete-pair-blink-delay))
|
2020-09-22 14:44:15 +00:00
|
|
|
|
(delete-char -1)))
|
|
|
|
|
(delete-char 1))))
|
2004-05-28 21:12:25 +00:00
|
|
|
|
|
|
|
|
|
(defun raise-sexp (&optional arg)
|
|
|
|
|
"Raise ARG sexps higher up the tree."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(let ((s (if (and transient-mark-mode mark-active)
|
|
|
|
|
(buffer-substring (region-beginning) (region-end))
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(point)
|
|
|
|
|
(save-excursion (forward-sexp arg) (point))))))
|
|
|
|
|
(backward-up-list 1)
|
|
|
|
|
(delete-region (point) (save-excursion (forward-sexp 1) (point)))
|
|
|
|
|
(save-excursion (insert s))))
|
|
|
|
|
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(defun move-past-close-and-reindent ()
|
|
|
|
|
"Move past next `)', delete indentation before it, then indent after it."
|
|
|
|
|
(interactive)
|
|
|
|
|
(up-list 1)
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
(while (save-excursion ; this is my contribution
|
|
|
|
|
(let ((before-paren (point)))
|
|
|
|
|
(back-to-indentation)
|
1997-09-07 01:12:07 +00:00
|
|
|
|
(and (= (point) before-paren)
|
|
|
|
|
(progn
|
|
|
|
|
;; Move to end of previous line.
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(forward-char -1)
|
|
|
|
|
;; Verify it doesn't end within a string or comment.
|
|
|
|
|
(let ((end (point))
|
|
|
|
|
state)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
;; Get state at start of line.
|
2000-01-05 15:08:36 +00:00
|
|
|
|
(setq state (list 0 nil nil
|
1997-09-07 01:12:07 +00:00
|
|
|
|
(null (calculate-lisp-indent))
|
|
|
|
|
nil nil nil nil
|
|
|
|
|
nil))
|
|
|
|
|
;; Parse state across the line to get state at end.
|
|
|
|
|
(setq state (parse-partial-sexp (point) end nil nil
|
|
|
|
|
state))
|
|
|
|
|
;; Check not in string or comment.
|
|
|
|
|
(and (not (elt state 3)) (not (elt state 4))))))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(delete-indentation))
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(newline-and-indent))
|
2000-01-05 15:08:36 +00:00
|
|
|
|
|
|
|
|
|
(defun check-parens () ; lame name?
|
|
|
|
|
"Check for unbalanced parentheses in the current buffer.
|
|
|
|
|
More accurately, check the narrowed part of the buffer for unbalanced
|
|
|
|
|
expressions (\"sexps\") in general. This is done according to the
|
|
|
|
|
current syntax table and will find unbalanced brackets or quotes as
|
2005-05-18 08:29:38 +00:00
|
|
|
|
appropriate. (See Info node `(emacs)Parentheses'.) If imbalance is
|
2005-06-21 13:44:23 +00:00
|
|
|
|
found, an error is signaled and point is left at the first unbalanced
|
2005-05-18 08:29:38 +00:00
|
|
|
|
character."
|
2000-01-05 15:08:36 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(condition-case data
|
|
|
|
|
;; Buffer can't have more than (point-max) sexps.
|
|
|
|
|
(scan-sexps (point-min) (point-max))
|
2015-02-18 07:41:10 +00:00
|
|
|
|
(scan-error (push-mark)
|
|
|
|
|
(goto-char (nth 2 data))
|
2000-01-05 15:08:36 +00:00
|
|
|
|
;; Could print (nth 1 data), which is either
|
|
|
|
|
;; "Containing expression ends prematurely" or
|
|
|
|
|
;; "Unbalanced parentheses", but those may not be so
|
|
|
|
|
;; accurate/helpful, e.g. quotes may actually be
|
|
|
|
|
;; mismatched.
|
2013-04-17 20:52:02 +00:00
|
|
|
|
(user-error "Unmatched bracket or quote"))))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
|
2007-11-26 20:27:12 +00:00
|
|
|
|
(defun field-complete (table &optional predicate)
|
2013-04-17 20:52:02 +00:00
|
|
|
|
(declare (obsolete completion-in-region "24.4"))
|
2009-08-30 15:13:35 +00:00
|
|
|
|
(let ((minibuffer-completion-table table)
|
|
|
|
|
(minibuffer-completion-predicate predicate)
|
|
|
|
|
;; This made sense for lisp-complete-symbol, but for
|
|
|
|
|
;; field-complete, this is out of place. --Stef
|
|
|
|
|
;; (completion-annotate-function
|
|
|
|
|
;; (unless (eq predicate 'fboundp)
|
|
|
|
|
;; (lambda (str)
|
|
|
|
|
;; (if (fboundp (intern-soft str)) " <f>"))))
|
|
|
|
|
)
|
|
|
|
|
(call-interactively 'minibuffer-complete)))
|
2007-11-26 20:27:12 +00:00
|
|
|
|
|
2015-05-16 13:53:44 +00:00
|
|
|
|
(defun lisp-complete-symbol (&optional _predicate)
|
1994-02-18 23:51:41 +00:00
|
|
|
|
"Perform completion on Lisp symbol preceding point.
|
|
|
|
|
Compare that symbol against the known Lisp symbols.
|
2002-01-11 21:22:28 +00:00
|
|
|
|
If no characters can be completed, display a list of possible completions.
|
|
|
|
|
Repeating the command at that point scrolls the list.
|
1994-02-18 23:51:41 +00:00
|
|
|
|
|
2015-05-16 13:53:44 +00:00
|
|
|
|
The context determines which symbols are considered. If the
|
|
|
|
|
symbol starts just after an open-parenthesis, only symbols with
|
|
|
|
|
function definitions are considered. Otherwise, all symbols with
|
|
|
|
|
function definitions, values or properties are considered."
|
2015-05-19 00:51:47 +00:00
|
|
|
|
(declare (obsolete completion-at-point "24.4")
|
|
|
|
|
(advertised-calling-convention () "25.1"))
|
1990-08-27 04:15:41 +00:00
|
|
|
|
(interactive)
|
2015-05-19 00:51:47 +00:00
|
|
|
|
(let* ((data (elisp-completion-at-point))
|
2009-12-07 20:06:26 +00:00
|
|
|
|
(plist (nthcdr 3 data)))
|
2010-04-27 17:57:32 +00:00
|
|
|
|
(if (null data)
|
|
|
|
|
(minibuffer-message "Nothing to complete")
|
2011-06-01 19:32:04 +00:00
|
|
|
|
(let ((completion-extra-properties plist))
|
|
|
|
|
(completion-in-region (nth 0 data) (nth 1 data) (nth 2 data)
|
2010-04-27 17:57:32 +00:00
|
|
|
|
(plist-get plist :predicate))))))
|
2010-04-20 07:54:28 +00:00
|
|
|
|
|
1992-05-30 22:12:04 +00:00
|
|
|
|
;;; lisp.el ends here
|