emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Removing ding each time I type TAB when not after a structure template with org-tempo enabled
@ 2018-02-04 19:07 Brent Goodrick
  2018-02-11 11:05 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Brent Goodrick @ 2018-02-04 19:07 UTC (permalink / raw)
  Cc: emacs-orgmode

Hi:

I recently upgraded to org from Git. Thus, org-version for me returns:

Org mode version 9.1.6 (release_9.1.6-425-gd89e35 @
/home/brentg/emacs_lisp_imported/org-mode/org-mode/lisp/)

In this new version, I discovered that structure templates were not
enabled by default, so I enabled them. But to my chagrin, I found that
I get a "ding" each time I type the TAB key when on a blank line that
is _not_ right after a structure template such as "<e".

Below is my hackaround, but can someone take a look into arranging it
so that is not the default to ding if tempo-complete-tag cannot find
anything to complete, and thus I can remove my hack?

Just passing silent to it will actually break TABing over (normal tab
meaning) in Org buffers, so the obvious fix won't work.  (ding)
returns nil which it must so that the hook works as expected.

Thanks,
Brent

----------------------------------------------------------

(defun bg-tempo-complete-tag-no-ding (&optional silent)
  ;; flet is NOT the same as cl-flet as it does not bind the function _deeply_
  ;; so that some function that calls the (ding) should pick up this definition
  ;; here. See https://emacs.stackexchange.com/a/3452/15483
  ;;
  ;; The reason we have to do it this way is because if tempo-complete-tag
  ;; returns t (which it will if we set its 'silent' argument to t), it
  ;; short-circuits the use of tempo-complete-tag from within
  ;; org-tab-before-tab-emulation-hook, which means even TABing to the line
  ;; underneath a Org check-list is broken (doesn't even tab). Ugggggh!
  ;;
  (cl-letf (((symbol-function 'ding)
         (lambda (&optional silent)
           ;; (message "bg-tempo-complete-tag-no-ding: Hack around bug
in ding in tempo-complete-tag or org mode")
           nil)))
    (tempo-complete-tag silent)))

(defun bg-org-enable-structure-templates ()
  ;;
  ;; Enable Structure templates that at one point were by default enabled in Org
  ;; mode, but someone changed that for some reason, so re enable it.
  ;;
  (require 'org-tempo)
  ;;
  ;; But tempo-complete-tag is obnoxious. It dings if you have point at the
  ;; start of a line (e.g., NOT after something like "<e"), and if it cannot
  ;; find a template prior to point, it dings. So disable that:
  ;;
  (remove-hook 'org-tab-before-tab-emulation-hook
           'tempo-complete-tag)
  (add-hook 'org-tab-before-tab-emulation-hook
        'bg-tempo-complete-tag-no-ding))


Thanks,
Brent

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Removing ding each time I type TAB when not after a structure template with org-tempo enabled
  2018-02-04 19:07 Removing ding each time I type TAB when not after a structure template with org-tempo enabled Brent Goodrick
@ 2018-02-11 11:05 ` Nicolas Goaziou
  2018-02-25 18:32   ` Brent Goodrick
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2018-02-11 11:05 UTC (permalink / raw)
  To: Brent Goodrick; +Cc: emacs-orgmode

Hello,

Brent Goodrick <bgoodr@gmail.com> writes:

> In this new version, I discovered that structure templates were not
> enabled by default, so I enabled them. But to my chagrin, I found that
> I get a "ding" each time I type the TAB key when on a blank line that
> is _not_ right after a structure template such as "<e".
>
> Below is my hackaround, but can someone take a look into arranging it
> so that is not the default to ding if tempo-complete-tag cannot find
> anything to complete, and thus I can remove my hack?
>
> Just passing silent to it will actually break TABing over (normal tab
> meaning) in Org buffers, so the obvious fix won't work.  (ding)
> returns nil which it must so that the hook works as expected.

Fixed. Thank you.

>   ;; Enable Structure templates that at one point were by default enabled in Org
>   ;; mode, but someone changed that for some reason, so re enable it.

There is another structure template expansion mechanism enable by
default. You may want to try `C-c C-x C-w'.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Removing ding each time I type TAB when not after a structure template with org-tempo enabled
  2018-02-11 11:05 ` Nicolas Goaziou
@ 2018-02-25 18:32   ` Brent Goodrick
  2018-02-27  1:05     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Brent Goodrick @ 2018-02-25 18:32 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

Hi Nicolas,

Thanks. This is close, but not completely fixed: When I have the point at
the start of a line in a Org file, and type the TAB key, it does not move
like it should up underneath the prior heading. See annotated screenshot:

https://i.imgur.com/zUH28W0.png

I'll have to re-instate my workaround for now.

Thanks for the help!

Brent


On Sun, Feb 11, 2018 at 3:05 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Brent Goodrick <bgoodr@gmail.com> writes:
>
> > In this new version, I discovered that structure templates were not
> > enabled by default, so I enabled them. But to my chagrin, I found that
> > I get a "ding" each time I type the TAB key when on a blank line that
> > is _not_ right after a structure template such as "<e".
> >
> > Below is my hackaround, but can someone take a look into arranging it
> > so that is not the default to ding if tempo-complete-tag cannot find
> > anything to complete, and thus I can remove my hack?
> >
> > Just passing silent to it will actually break TABing over (normal tab
> > meaning) in Org buffers, so the obvious fix won't work.  (ding)
> > returns nil which it must so that the hook works as expected.
>
> Fixed. Thank you.
>
> >   ;; Enable Structure templates that at one point were by default
> enabled in Org
> >   ;; mode, but someone changed that for some reason, so re enable it.
>
> There is another structure template expansion mechanism enable by
> default. You may want to try `C-c C-x C-w'.
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #2: Type: text/html, Size: 2305 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Removing ding each time I type TAB when not after a structure template with org-tempo enabled
  2018-02-25 18:32   ` Brent Goodrick
@ 2018-02-27  1:05     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2018-02-27  1:05 UTC (permalink / raw)
  To: Brent Goodrick; +Cc: emacs-orgmode

Hello,

Brent Goodrick <bgoodr@gmail.com> writes:

> Thanks. This is close, but not completely fixed: When I have the point at
> the start of a line in a Org file, and type the TAB key, it does not move
> like it should up underneath the prior heading.

I see. I pushed another fix into master. Hopefully, this is now
completely fixed.

Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-27  1:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-04 19:07 Removing ding each time I type TAB when not after a structure template with org-tempo enabled Brent Goodrick
2018-02-11 11:05 ` Nicolas Goaziou
2018-02-25 18:32   ` Brent Goodrick
2018-02-27  1:05     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).