From: Sebastian Wiesner <lunaryorn@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Mark custom function for interactive use only
Date: Mon, 25 Nov 2013 12:33:08 +0100 [thread overview]
Message-ID: <CALf2awT72XKhm35+Er9rsWefL+dAhC5W88_8AVQkKZ4dRNRquA@mail.gmail.com> (raw)
In-Reply-To: <CALf2awSV1hXQDCw_mnKvGPADeQB7HvmbjLPOHc2R7DKS1e_org@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1057 bytes --]
2013/11/25 Sebastian Wiesner <lunaryorn@gmail.com>:
> 2013/11/25 Sebastian Wiesner <lunaryorn@gmail.com>:
>> 2013/11/25 Stefan Monnier <monnier@iro.umontreal.ca>:
>>>> I presume I'd just patch `byte-compile-form' in bytecomp.el to also
>>>> look at a corresponding property, e.g. `interactive-use-only`.
>>>> Anything else?
>>>
>>> We should also make byte-compile-interactive-only-functions obsolete and
>>> default it to nil (i.e. move its contents to symbol properties).
>>
>> Attached is a patch to Emacs trunk, which introduces a
>> `interactive-only' symbol property as either a string with a "use
>> instead" message or just t, sets this property on all functions from
>> byte-compile-interactive-only-functions, and makes
>> byte-compile-interactive-only-functions as obsolete.
>>
>> Documentation and tests are missing. If you can point me to the
>> proper places and tell me how to run the Emacs tests, I can add these
>> as well.
>
> Ok, *now* it's attached. Sorry
I fixed a little mistake, please use the patch attached to this mail instead.
[-- Attachment #2: interactive-only-property.patch --]
[-- Type: application/octet-stream, Size: 6557 bytes --]
=== modified file 'lisp/comint.el'
--- lisp/comint.el 2013-10-29 16:11:50 +0000
+++ lisp/comint.el 2013-11-25 10:37:38 +0000
@@ -752,6 +752,7 @@
(let ((name (file-name-nondirectory program)))
(switch-to-buffer (make-comint name program))
(run-hooks (intern-soft (concat "comint-" name "-hook")))))
+(put 'comint-run 'interactive-only t)
(defun comint-exec (buffer name command startfile switches)
"Start up a process named NAME in buffer BUFFER for Comint modes.
=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- lisp/emacs-lisp/bytecomp.el 2013-10-30 02:45:53 +0000
+++ lisp/emacs-lisp/bytecomp.el 2013-11-25 11:31:48 +0000
@@ -353,11 +353,11 @@
(t
(append byte-compile-warnings (list warning)))))))
-(defvar byte-compile-interactive-only-functions
- '(beginning-of-buffer end-of-buffer replace-string replace-regexp
- insert-file insert-buffer insert-file-literally previous-line next-line
- goto-line comint-run delete-backward-char)
+(defvar byte-compile-interactive-only-functions nil
"List of commands that are not meant to be called from Lisp.")
+(make-obsolete-variable 'byte-compile-interactive-only-functions
+ "use the `interactive-only' symbol property instead"
+ "24.4")
(defvar byte-compile-not-obsolete-vars nil
"List of variables that shouldn't be reported as obsolete.")
@@ -2929,13 +2929,19 @@
(byte-compile-variable-ref form))))
((symbolp (car form))
(let* ((fn (car form))
- (handler (get fn 'byte-compile)))
+ (handler (get fn 'byte-compile))
+ (interactive-only (or (get fn 'interactive-only)
+ (memq fn byte-compile-interactive-only-functions))))
(when (macroexp--const-symbol-p fn)
(byte-compile-warn "`%s' called as a function" fn))
- (and (byte-compile-warning-enabled-p 'interactive-only)
- (memq fn byte-compile-interactive-only-functions)
- (byte-compile-warn "`%s' used from Lisp code\n\
-That command is designed for interactive use only" fn))
+ (when (and (byte-compile-warning-enabled-p 'interactive-only)
+ interactive-only)
+ (byte-compile-warn "`%s' used from Lisp code\n\
+That command is designed for interactive use only.\n%s"
+ fn
+ (if (stringp interactive-only)
+ interactive-only
+ "Consult the documentation for an alternative")))
(if (and (fboundp (car form))
(eq (car-safe (symbol-function (car form))) 'macro))
(byte-compile-log-warning
=== modified file 'lisp/files.el'
--- lisp/files.el 2013-10-30 02:14:16 +0000
+++ lisp/files.el 2013-11-25 10:33:10 +0000
@@ -2085,6 +2085,8 @@
\(Its calling sequence is different; see its documentation)."
(interactive "*fInsert file literally: ")
(insert-file-1 filename #'insert-file-contents-literally))
+(put 'insert-file-literally 'interactive-only
+ "Use `insert-file-contents-literally' instead")
(defvar find-file-literally nil
"Non-nil if this buffer was made by `find-file-literally' or equivalent.
@@ -5007,6 +5009,7 @@
\(Its calling sequence is different; see its documentation)."
(interactive "*fInsert file: ")
(insert-file-1 filename #'insert-file-contents))
+(put 'insert-file 'interactive-only "Use `insert-file-contents' instead.")
(defun append-to-file (start end filename)
"Append the contents of the region to the end of file FILENAME.
=== modified file 'lisp/replace.el'
--- lisp/replace.el 2013-11-13 20:48:35 +0000
+++ lisp/replace.el 2013-11-25 10:31:11 +0000
@@ -523,6 +523,8 @@
(if (and transient-mark-mode mark-active)
(region-end)))))
(perform-replace from-string to-string nil nil delimited nil nil start end))
+(put 'replace-string 'interactive-only
+ "Use `search-forward' and `replace-match' instead.")
(defun replace-regexp (regexp to-string &optional delimited start end)
"Replace things after point matching REGEXP with TO-STRING.
@@ -590,6 +592,8 @@
(if (and transient-mark-mode mark-active)
(region-end)))))
(perform-replace regexp to-string nil t delimited nil nil start end))
+(put 'replace-regexp 'interactive-only
+ "Use `re-search-forward' and `replace-match' instead.")
\f
(defvar regexp-history nil
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2013-10-30 02:45:53 +0000
+++ lisp/simple.el 2013-11-25 10:38:10 +0000
@@ -888,6 +888,7 @@
(/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
(point-min))))
(if (and arg (not (consp arg))) (forward-line 1)))
+(put 'beginning-of-buffer 'interactive-only "Use (goto-char (point-min)) instead")
(defun end-of-buffer (&optional arg)
"Move point to the end of the buffer.
@@ -920,6 +921,7 @@
;; then scroll specially to put it near, but not at, the bottom.
(overlay-recenter (point))
(recenter -3))))
+(put 'end-of-buffer 'interactive-only "Use (goto-char (point-max)) instead")
(defcustom delete-active-region t
"Whether single-char deletion commands delete an active region.
@@ -982,6 +984,7 @@
(insert-char ?\s (- ocol (current-column)) nil))))
;; Otherwise, do simple deletion.
(t (delete-char (- n) killflag))))
+(put 'delete-backward-char 'interactive-only t)
(defun delete-forward-char (n &optional killflag)
"Delete the following N characters (previous if N is negative).
@@ -1079,6 +1082,7 @@
(if (eq selective-display t)
(re-search-forward "[\n\C-m]" nil 'end (1- line))
(forward-line (1- line)))))
+(put 'goto-line 'interactive-only "Use `forward-line' instead")
(defun count-words-region (start end &optional arg)
"Count the number of words in the region.
@@ -4165,6 +4169,7 @@
(insert-buffer-substring (get-buffer buffer))
(point)))
nil)
+(put 'insert-buffer 'interactive-only "Use `insert-buffer-substring' instead")
(defun append-to-buffer (buffer start end)
"Append to specified buffer the text of the region.
@@ -4763,6 +4768,7 @@
(signal (car err) (cdr err))))
(line-move arg nil nil try-vscroll)))
nil)
+(put 'next-line 'interactive-only "Use `forward-line' instead")
(defun previous-line (&optional arg try-vscroll)
"Move cursor vertically up ARG lines.
@@ -4802,6 +4808,8 @@
(signal (car err) (cdr err))))
(line-move (- arg) nil nil try-vscroll))
nil)
+(put 'previous-line 'interactive-only
+ "Use `forward-line' with negative argument instead")
(defcustom track-eol nil
"Non-nil means vertical motion starting at end of line keeps to ends of lines.
next prev parent reply other threads:[~2013-11-25 11:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-24 15:29 Mark custom function for interactive use only Sebastian Wiesner
2013-11-24 18:22 ` Stefan Monnier
2013-11-24 19:52 ` Sebastian Wiesner
2013-11-25 3:10 ` Stefan Monnier
2013-11-25 10:05 ` Sebastian Wiesner
2013-11-25 10:41 ` Sebastian Wiesner
2013-11-25 10:42 ` Sebastian Wiesner
2013-11-25 10:54 ` Bozhidar Batsov
2013-11-25 11:34 ` Sebastian Wiesner
2013-11-25 13:11 ` Bozhidar Batsov
2013-11-25 11:33 ` Sebastian Wiesner [this message]
2013-11-25 14:58 ` Stefan Monnier
2013-11-25 15:42 ` Sebastian Wiesner
2013-11-25 17:17 ` Bozhidar Batsov
2013-11-25 17:48 ` Sebastian Wiesner
2013-11-25 19:36 ` Bozhidar Batsov
2013-11-26 3:18 ` Glenn Morris
2013-11-26 6:46 ` Bozhidar Batsov
2013-11-26 9:06 ` Andreas Schwab
2013-11-26 9:24 ` Bozhidar Batsov
[not found] ` <CALf2awQ3TJcNq2GiXObEgPBm+JOqrveNrEaTak0E0ws+jrh3dw@mail.gmail.com>
2013-11-26 9:55 ` Bozhidar Batsov
2013-11-26 19:46 ` Glenn Morris
2013-11-26 21:16 ` Sebastian Wiesner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALf2awT72XKhm35+Er9rsWefL+dAhC5W88_8AVQkKZ4dRNRquA@mail.gmail.com \
--to=lunaryorn@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).