GNU bug report logs -
#10772
24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode
Previous Next
Reported by: William Stevenson <yhvh2000 <at> gmail.com>
Date: Thu, 9 Feb 2012 06:51:01 UTC
Severity: minor
Tags: fixed, patch
Found in version 24.0.93
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10772 in the body.
You can then email your comments to 10772 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 09 Feb 2012 06:51:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
William Stevenson <yhvh2000 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 09 Feb 2012 06:51:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In the documentation of auto-fill-mode it says:
"When `auto-fill-mode' is on, the `auto-fill-function' variable is
non-`nil'."
Which makes the `if' redundant in this case, the THEN & ELSE bodies can
be placed below the call to turn auto-fill-mode on/off.
Also updated the documentation to reflect the auto generated
`tcl-auto-fill-mode-hook'.
=== modified file 'lisp/progmodes/tcl.el'
--- lisp/progmodes/tcl.el 2012-01-19 07:21:25 +0000
+++ lisp/progmodes/tcl.el 2012-02-09 06:18:32 +0000
@@ -1408,13 +1408,18 @@
tcl-application file tcl-command-switches)
(if and-go (switch-to-tcl t)))))))
-(defun tcl-auto-fill-mode (&optional arg)
- "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
- (interactive "P")
- (auto-fill-mode arg)
- (if auto-fill-function
- (set (make-local-variable 'comment-auto-fill-only-comments) t)
- (kill-local-variable 'comment-auto-fill-only-comments)))
+(define-minor-mode tcl-auto-fill-mode
+ "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'.
+Turning the mode on or off runs `tcl-auto-fill-mode-hook'."
+ :init-value nil
+ (cond ((null tcl-auto-fill-mode)
+ ;; Turn mode off
+ (auto-fill-mode 0)
+ (kill-local-variable 'comment-auto-fill-only-comments))
+ (t
+ ;; Turn mode on
+ (auto-fill-mode)
+ (set (make-local-variable 'comment-auto-fill-only-comments) t))))
(defun tcl-electric-hash (&optional count)
"Insert a `#' and quote if it does not start a real comment.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 09 Feb 2012 15:21:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 10772 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 9, 2012 at 07:49, William Stevenson <yhvh2000 <at> gmail.com> wrote:
> + (auto-fill-mode)
That is correct, but I think it is customary (and clearer IMHO) to
pass an explicit argument, like (auto-fill-mode 1)
Juanma
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 09 Feb 2012 22:11:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 10772 <at> debbugs.gnu.org (full text, mbox):
> -(defun tcl-auto-fill-mode (&optional arg)
> - "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
> - (interactive "P")
> - (auto-fill-mode arg)
> - (if auto-fill-function
> - (set (make-local-variable 'comment-auto-fill-only-comments) t)
> - (kill-local-variable 'comment-auto-fill-only-comments)))
> +(define-minor-mode tcl-auto-fill-mode
> + "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'.
> +Turning the mode on or off runs `tcl-auto-fill-mode-hook'."
> + :init-value nil
> + (cond ((null tcl-auto-fill-mode)
> + ;; Turn mode off
> + (auto-fill-mode 0)
> + (kill-local-variable 'comment-auto-fill-only-comments))
> + (t
> + ;; Turn mode on
> + (auto-fill-mode)
> + (set (make-local-variable 'comment-auto-fill-only-comments) t))))
The problem with this approach is that it creates new possible states,
e.g. if the user enables tcl-auto-fill-mode and then disables
auto-fill-mode.
Maybe we could use an approach like the one I used for
(binary-)overwrite-mode.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Sat, 11 Feb 2012 15:30:01 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> The problem with this approach is that it creates new possible states,
> e.g. if the user enables tcl-auto-fill-mode and then disables
> auto-fill-mode.
The correct behavior seems to be if the tcl-auto-fill-mode is enabled
then calling auto-fill-mode will turn *auto-fill-mode off.
> Maybe we could use an approach like the one I used for
> (binary-)overwrite-mode.
I've been looking at this for the past day or so, and I'm still not sure
I know exactly what to do, but I've come up with 2 options.
This option works as I expect, ie when tcl-auto-fill-mode is enabled,
calling auto-fill-mode disables tcl-auto-fill-mode and auto-fill-mode.
--8<---------------cut here---------------start------------->8---
;; Docstrings elided
(define-minor-mode tcl-auto-fill-mode
:variable (eq auto-fill-function normal-auto-fill-function)
(if auto-fill-function
(kill-local-variable 'comment-auto-fill-only-comments)
(set (make-local-variable 'comment-auto-fill-only-comments) t)))
--8<---------------cut here---------------end--------------->8---
Or something more like this, which seems more in the spirit of binary
overwrite mode.
--8<---------------cut here---------------start------------->8---
;; Docstrings elided
(defun tcl-do-auto-fill ()
(if auto-fill-function
(kill-local-variable 'comment-auto-fill-only-comments)
(set (make-local-variable 'comment-auto-fill-only-comments) t))
(do-auto-fill))
(defvar tcl-auto-fill-function 'tcl-do-auto-fill)
(define-minor-mode tcl-auto-fill-mode
:variable (eq auto-fill-function tcl-auto-fill-function))
--8<---------------cut here---------------end--------------->8---
However other progmodes define f90-do-auto-fill, c-do-auto-fill,
cperl-do-auto-fill but tend to do the following.
--8<---------------cut here---------------start------------->8---
(set (make-local-variable 'normal-auto-fill-function) 'foo-do-auto-fill)
--8<---------------cut here---------------end--------------->8---
These 3 modes (and some others from cursory checking) don't define
foo-auto-fill-mode and just let the user call auto-fill-mode - which
makes me wonder if defining tcl-auto-fill-mode is the right thing to do
anyway.
William
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Sun, 12 Feb 2012 15:17:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 10772 <at> debbugs.gnu.org (full text, mbox):
> --8<---------------cut here---------------start------------->8---
> (set (make-local-variable 'normal-auto-fill-function) 'foo-do-auto-fill)
> --8<---------------cut here---------------end--------------->8---
> These 3 modes (and some others from cursory checking) don't define
> foo-auto-fill-mode and just let the user call auto-fill-mode - which
> makes me wonder if defining tcl-auto-fill-mode is the right thing to do
> anyway.
Actually, thinking about it some more, maybe tcl-auto-fill-mode should
be renamed (it has nothing specific to Tcl) and I think it could be
implemented along the lines of (100% untested):
(define-minor-mode auto-fill-noncode-mode
:variable
((and auto-fill-function comment-auto-fill-only-comments)
. (lambda (x)
(auto-fill-mode (if x 1 -1))
(if auto-fill-function
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(kill-local-variable 'comment-auto-fill-only-comments)))))
-- Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Tue, 25 Feb 2014 13:31:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 10772 <at> debbugs.gnu.org (full text, mbox):
What about the following patch:
=== modified file 'lisp/progmodes/tcl.el'
--- lisp/progmodes/tcl.el 2014-02-10 01:34:22 +0000
+++ lisp/progmodes/tcl.el 2014-02-25 13:22:36 +0000
@@ -1410,13 +1410,8 @@
tcl-application file tcl-command-switches)
(if and-go (switch-to-tcl t)))))))
-(defun tcl-auto-fill-mode (&optional arg)
- "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
- (interactive "P")
- (auto-fill-mode arg)
- (if auto-fill-function
- (set (make-local-variable 'comment-auto-fill-only-comments) t)
- (kill-local-variable 'comment-auto-fill-only-comments)))
+(define-obsolete-function-alias tcl-auto-fill-mode
+ auto-fill-noncode-mode "24.4")
(defun tcl-electric-hash (&optional count)
"Insert a `#' and quote if it does not start a real comment.
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2014-02-21 13:22:14 +0000
+++ lisp/simple.el 2014-02-25 13:26:54 +0000
@@ -6146,6 +6146,16 @@
. (lambda (v) (setq auto-fill-function
(if v normal-auto-fill-function)))))
+(define-minor-mode auto-fill-noncode-mode
+ "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
+ :variable
+ ((and auto-fill-function comment-auto-fill-only-comments)
+ . (lambda (x)
+ (auto-fill-mode (if x 1 -1))
+ (if auto-fill-function
+ (setq-local comment-auto-fill-only-comments t)
+ (kill-local-variable 'comment-auto-fill-only-comments)))))
+
;; This holds a document string used to document auto-fill-mode.
(defun auto-fill-function ()
"Automatically break line at a previous space, in insertion of text."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Tue, 25 Feb 2014 14:31:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 10772 <at> debbugs.gnu.org (full text, mbox):
> What about the following patch:
Tcl is not special wrt to filling and comments, AFAIK, so tcl-mode
should simply use the default auto-fill functionality without any
local tweaks.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Tue, 25 Feb 2014 22:26:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 10772 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> What about the following patch:
>
> Tcl is not special wrt to filling and comments, AFAIK, so tcl-mode
> should simply use the default auto-fill functionality without any
> local tweaks.
Right, and that's exactly what my patch does.
--
http://www.gnu.org/software/emacs/
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Wed, 26 Feb 2014 15:42:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 10772 <at> debbugs.gnu.org (full text, mbox):
>>> What about the following patch:
>> Tcl is not special wrt to filling and comments, AFAIK, so tcl-mode
>> should simply use the default auto-fill functionality without any
>> local tweaks.
> Right, and that's exactly what my patch does.
No, it preserves the "special behavior", just changing the
implementation to rely on the generic auto-fill code. My point is that
the special behavior is just a preference of the mode's author and hence
doesn't belong in the major mode's definition.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Wed, 26 Feb 2014 22:41:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 10772 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>>> Tcl is not special wrt to filling and comments, AFAIK, so tcl-mode
>>> should simply use the default auto-fill functionality without any
>>> local tweaks.
>> Right, and that's exactly what my patch does.
>
> No, it preserves the "special behavior", just changing the
> implementation to rely on the generic auto-fill code. My point is that
> the special behavior is just a preference of the mode's author and hence
> doesn't belong in the major mode's definition.
Ah, I see. So here's the new patch (without ChangeLog/NEWS):
=== modified file 'lisp/progmodes/tcl.el'
--- lisp/progmodes/tcl.el 2014-02-10 01:34:22 +0000
+++ lisp/progmodes/tcl.el 2014-02-26 22:39:06 +0000
@@ -1410,13 +1410,8 @@
tcl-application file tcl-command-switches)
(if and-go (switch-to-tcl t)))))))
-(defun tcl-auto-fill-mode (&optional arg)
- "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
- (interactive "P")
- (auto-fill-mode arg)
- (if auto-fill-function
- (set (make-local-variable 'comment-auto-fill-only-comments) t)
- (kill-local-variable 'comment-auto-fill-only-comments)))
+(define-obsolete-function-alias tcl-auto-fill-mode
+ auto-fill-mode "24.4")
(defun tcl-electric-hash (&optional count)
"Insert a `#' and quote if it does not start a real comment.
--
http://www.gnu.org/software/emacs/
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 27 Feb 2014 02:56:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 10772 <at> debbugs.gnu.org (full text, mbox):
> Ah, I see. So here's the new patch (without ChangeLog/NEWS):
Looks better. Please also get rid of existing uses of
tcl-auto-fill-mode. And of course, wait for the trunk to re-open before
installing it.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 27 Feb 2014 17:01:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 10772 <at> debbugs.gnu.org (full text, mbox):
Xue Fuqiao wrote:
> +(define-obsolete-function-alias tcl-auto-fill-mode
> + auto-fill-mode "24.4")
Surely that is missing some quotes and can't work?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Thu, 27 Feb 2014 22:34:01 GMT)
Full text and
rfc822 format available.
Message #41 received at 10772 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
> Xue Fuqiao wrote:
>
>> +(define-obsolete-function-alias tcl-auto-fill-mode
>> + auto-fill-mode "24.4")
>
> Surely that is missing some quotes and can't work?
Sorry for that. I'll add them when installing.
--
http://www.gnu.org/software/emacs/
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Wed, 24 Feb 2016 06:43:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 10772 <at> debbugs.gnu.org (full text, mbox):
Xue Fuqiao <xfq <at> gnu.org> writes:
> Glenn Morris <rgm <at> gnu.org> writes:
>
>> Xue Fuqiao wrote:
>>
>>> +(define-obsolete-function-alias tcl-auto-fill-mode
>>> + auto-fill-mode "24.4")
>>
>> Surely that is missing some quotes and can't work?
>
> Sorry for that. I'll add them when installing.
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> Ah, I see. So here's the new patch (without ChangeLog/NEWS):
>
> Looks better. Please also get rid of existing uses of
> tcl-auto-fill-mode. And of course, wait for the trunk to re-open before
> installing it.
The trunk has been open for a few years now, but this doesn't seem to
have been applied. Xue?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Sat, 03 Jun 2017 03:44:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 10772 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Xue Fuqiao <xfq <at> gnu.org> writes:
> +(define-obsolete-function-alias tcl-auto-fill-mode
> + auto-fill-mode "24.4")
I think making this an alias breaks backwards compatibility needlessly.
I propose just marking it obsolete without changing it:
[v1-0001-Make-tcl-auto-fill-mode-obsolete-Bug-10772.patch (text/x-diff, inline)]
From dd1ba59961cc216422349716fcfc62e656076500 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 1 Apr 2017 21:02:50 -0400
Subject: [PATCH v1] Make tcl-auto-fill-mode obsolete (Bug#10772)
* lisp/progmodes/tcl.el (tcl-auto-fill-mode): Declare obsolete.
* etc/NEWS: Announce it.
---
etc/NEWS | 5 +++++
lisp/progmodes/tcl.el | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 7972511f7a..cbd388b216 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1306,6 +1306,11 @@ window changed size when 'window-size-change-functions' are run.
*** The semantics of 'mouse-autoselect-window' has changed slightly.
For details see the section "Mouse Window Auto-selection" in the Elisp
manual.
+
+---
+** 'tcl-auto-fill-mode' is now declared obsolete. It's functionality
+can be replicated simply by setting 'comment-auto-fill-only-comments'.
+
* Changes in Emacs 26.1 on Non-Free Operating Systems
diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index 902a5aace0..de0cd50911 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -353,8 +353,6 @@ (defvar tcl-mode-hook nil
Quotes all \"#\" characters that don't correspond to actual
Tcl comments. (Useful when editing code not originally created
with this mode).
- `tcl-auto-fill-mode'
- Auto-filling of Tcl comments.
Add functions to the hook with `add-hook':
@@ -1413,6 +1411,9 @@ (defun tcl-restart-with-file (file &optional and-go)
(defun tcl-auto-fill-mode (&optional arg)
"Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
+ (declare
+ (obsolete
+ "Use `auto-fill-mode' with `comment-auto-fill-only-comments'." "26.1"))
(interactive "P")
(auto-fill-mode arg)
(if auto-fill-function
--
2.11.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10772
; Package
emacs
.
(Wed, 28 Jun 2017 00:38:01 GMT)
Full text and
rfc822 format available.
Message #50 received at 10772 <at> debbugs.gnu.org (full text, mbox):
tags 10772 fixed
close 10772 26.1
quit
npostavs <at> users.sourceforge.net writes:
> I think making this an alias breaks backwards compatibility needlessly.
> I propose just marking it obsolete without changing it:
Pushed to master: [1: e06b547e93].
[1: e06b547e93]: 2017-06-27 20:34:14 -0400
Make tcl-auto-fill-mode obsolete (Bug#10772)
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e06b547e9369cb7c9c77b81041003bb120170929
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 28 Jun 2017 00:38:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
10772 <at> debbugs.gnu.org and William Stevenson <yhvh2000 <at> gmail.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 28 Jun 2017 00:38:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 26 Jul 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 45 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.