emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* electric-pair, autopair, smartparens, etc in org-mode
@ 2018-10-21  0:36 Matt Price
  2018-10-21  7:28 ` Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Matt Price @ 2018-10-21  0:36 UTC (permalink / raw)
  To: Org Mode

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

Hi eveyrone,

I'm just wondering what tools other people use to manage paired parentheses
and other markers in org.  I'm revisiting my long-ago decision to turn all
pairing tools off in org, but every tool I try is pretty frustrating out of
the box:

- smartparens steals a large number of really important structure-editing
commands from org-mode.  I find the default behaviour unusable.
- electric-pair and autopair complete [[ immediately, and don't seem to
allow me to skip past the closing brackets, so if I try to type [[
https://link.to.somewhere][link text]] I end up with
[[link.to.somewhere]][link-text] .

I'm willing to learn how to use these modes properly but I'm not quite sure
how best to proceed, so if someone else has a solution that works I would
be very grateful to hear it. thank you!

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

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-21  0:36 electric-pair, autopair, smartparens, etc in org-mode Matt Price
@ 2018-10-21  7:28 ` Nicolas Goaziou
  2018-10-21 16:43   ` Matt Price
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2018-10-21  7:28 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Hello,

Matt Price <moptop99@gmail.com> writes:

> - electric-pair and autopair complete [[ immediately, and don't seem to
> allow me to skip past the closing brackets, so if I try to type [[
> https://link.to.somewhere][link text]] I end up with
> [[link.to.somewhere]][link-text] .

I use C-c C-l to insert links with description. However, electric
pairing does get in the way when writing sub/superscript. I use the
following snippet to work around the issue:

   (add-function :before-until electric-pair-inhibit-predicate
                 (lambda (c)
                   (and (eq ?\{ c)
                        (eq major-mode 'org-mode)
                        (memq (char-before (1- (point))) '(?_ ?^)))))

I guess you could do something similar to disable pairing when entering
a bracket link.

Regards,

-- 
Nicolas Goaziou

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-21  7:28 ` Nicolas Goaziou
@ 2018-10-21 16:43   ` Matt Price
  2018-10-23  7:58     ` Roland Everaert
  0 siblings, 1 reply; 16+ messages in thread
From: Matt Price @ 2018-10-21 16:43 UTC (permalink / raw)
  To: Org Mode

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

wow, I learned a whole lot from your answer Nicholas, but still not quite
enough to make this work for me.  After some puzzling over the syntax for
character values, I believe that what I want should be something like this:

(add-function :before-until electric-pair-inhibit-predicate
              (lambda (c)
                (and (eq ?\[ c)
                     (eq major-mode 'org-mode)
                     (memq (char-before (1- (point))) '(?\[ ?\])))))

The manual says to use advice-add instead of add-function for these cases,
so this could be written like this instead:

(defun mwp-org-mode-electric-inhibit (c)
  (and
   (eq ?\[ c)
   (eq major-mode 'org-mode)
   (memq (char-before (1- (point))) '(?\[ ?\]) )))

(advice-add electric-pair-inhibit-predicate :before-until
#'mwp-org-mode-electric-inhibit)

it seems to sort of work.  That is, the code is effective, but it doesn't
do what I want, so I had to think about the desired behaviour, which is
maybe too complex for this modification:

when I start a link [
go ahead and add pair to
[]
when I add a second [, don't complete
[[]
this is what my code does!

but what I really want is, when I finish adding a link reference, somehow
allow me to stay inside the link to add the link text:
[[https://google.com]] --> [[https://google.com][]]
with point between the final [ and ].
This seems like it needs a more complex intervention.

For now I've just turned off pairing of brackets entirely:

(defun mwp-org-mode-electric-inhibit (c)
  (and
   (eq ?\[ c)
   (eq major-mode 'org-mode))

This works fine, though I'd still like the other :-/

Thanks Nicholas!
On Sun, Oct 21, 2018 at 3:28 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Matt Price <moptop99@gmail.com> writes:
>
> > - electric-pair and autopair complete [[ immediately, and don't seem to
> > allow me to skip past the closing brackets, so if I try to type [[
> > https://link.to.somewhere][link text]] I end up with
> > [[link.to.somewhere]][link-text] .
>
> I use C-c C-l to insert links with description. However, electric
> pairing does get in the way when writing sub/superscript. I use the
> following snippet to work around the issue:
>
>    (add-function :before-until electric-pair-inhibit-predicate
>                  (lambda (c)
>                    (and (eq ?\{ c)
>                         (eq major-mode 'org-mode)
>                         (memq (char-before (1- (point))) '(?_ ?^)))))
>
> I guess you could do something similar to disable pairing when entering
> a bracket link.
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-21 16:43   ` Matt Price
@ 2018-10-23  7:58     ` Roland Everaert
  2018-10-23 11:48       ` stardiviner
  0 siblings, 1 reply; 16+ messages in thread
From: Roland Everaert @ 2018-10-23  7:58 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

Hi,

I use the following configuration:

    ;;;;;;;;;;;;;;;; parenthèses, accolades et brackets ;;;;;;
    (setq skeleton-pair t)
    (global-set-key "[" 'skeleton-pair-insert-maybe)
    (global-set-key "{" 'skeleton-pair-insert-maybe)
    (global-set-key "(" 'skeleton-pair-insert-maybe)
    (global-set-key "\"" 'skeleton-pair-insert-maybe)
    (global-set-key "'" 'skeleton-pair-insert-maybe)

This will only close the defined characters.


Hope this will help.

Roland.

Matt Price writes:

> wow, I learned a whole lot from your answer Nicholas, but still not quite
> enough to make this work for me.  After some puzzling over the syntax for
> character values, I believe that what I want should be something like this:
>
> (add-function :before-until electric-pair-inhibit-predicate
>               (lambda (c)
>                 (and (eq ?\[ c)
>                      (eq major-mode 'org-mode)
>                      (memq (char-before (1- (point))) '(?\[ ?\])))))
>
> The manual says to use advice-add instead of add-function for these cases,
> so this could be written like this instead:
>
> (defun mwp-org-mode-electric-inhibit (c)
>   (and
>    (eq ?\[ c)
>    (eq major-mode 'org-mode)
>    (memq (char-before (1- (point))) '(?\[ ?\]) )))
>
> (advice-add electric-pair-inhibit-predicate :before-until
> #'mwp-org-mode-electric-inhibit)
>
> it seems to sort of work.  That is, the code is effective, but it doesn't
> do what I want, so I had to think about the desired behaviour, which is
> maybe too complex for this modification:
>
> when I start a link [
> go ahead and add pair to
> []
> when I add a second [, don't complete
> [[]
> this is what my code does!
>
> but what I really want is, when I finish adding a link reference, somehow
> allow me to stay inside the link to add the link text:
> [[https://google.com]] --> [[https://google.com][]]
> with point between the final [ and ].
> This seems like it needs a more complex intervention.
>
> For now I've just turned off pairing of brackets entirely:
>
> (defun mwp-org-mode-electric-inhibit (c)
>   (and
>    (eq ?\[ c)
>    (eq major-mode 'org-mode))
>
> This works fine, though I'd still like the other :-/
>
> Thanks Nicholas!
> On Sun, Oct 21, 2018 at 3:28 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
> wrote:
>
>> Hello,
>>
>> Matt Price <moptop99@gmail.com> writes:
>>
>> > - electric-pair and autopair complete [[ immediately, and don't seem to
>> > allow me to skip past the closing brackets, so if I try to type [[
>> > https://link.to.somewhere][link text]] I end up with
>> > [[link.to.somewhere]][link-text] .
>>
>> I use C-c C-l to insert links with description. However, electric
>> pairing does get in the way when writing sub/superscript. I use the
>> following snippet to work around the issue:
>>
>>    (add-function :before-until electric-pair-inhibit-predicate
>>                  (lambda (c)
>>                    (and (eq ?\{ c)
>>                         (eq major-mode 'org-mode)
>>                         (memq (char-before (1- (point))) '(?_ ?^)))))
>>
>> I guess you could do something similar to disable pairing when entering
>> a bracket link.
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou
>>


-- 
Luke, use the FOSS

Sent from Emacs

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-23  7:58     ` Roland Everaert
@ 2018-10-23 11:48       ` stardiviner
  2018-10-23 13:07         ` Eric S Fraga
  2018-10-24 10:38         ` Roland Everaert
  0 siblings, 2 replies; 16+ messages in thread
From: stardiviner @ 2018-10-23 11:48 UTC (permalink / raw)
  To: Roland Everaert; +Cc: Org Mode


Roland Everaert <reveatwork@gmail.com> writes:

> Hi,
>
> I use the following configuration:
>
>     ;;;;;;;;;;;;;;;; parenthèses, accolades et brackets ;;;;;;
>     (setq skeleton-pair t)
>     (global-set-key "[" 'skeleton-pair-insert-maybe)
>     (global-set-key "{" 'skeleton-pair-insert-maybe)
>     (global-set-key "(" 'skeleton-pair-insert-maybe)
>     (global-set-key "\"" 'skeleton-pair-insert-maybe)
>     (global-set-key "'" 'skeleton-pair-insert-maybe)
>
> This will only close the defined characters.
>
>
> Hope this will help.
>
> Roland.
>

This is really helpful for me, I use smartparens before, but it is a little heavy. So I disabled it. I found your solution is simple and fast. I modified a little:

#+begin_src emacs-lisp
(require 'skeleton)
(setq skeleton-pair t)

(define-key org-mode-map (kbd "~") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "=") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "*") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "+") 'skeleton-pair-insert-maybe)

(define-key org-mode-map (kbd "[") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "{") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "(") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "\"") 'skeleton-pair-insert-maybe)
(define-key org-mode-map (kbd "'") 'skeleton-pair-insert-maybe)
#+end_src

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-23 11:48       ` stardiviner
@ 2018-10-23 13:07         ` Eric S Fraga
  2018-10-24 13:12           ` Matt Price
  2018-10-24 10:38         ` Roland Everaert
  1 sibling, 1 reply; 16+ messages in thread
From: Eric S Fraga @ 2018-10-23 13:07 UTC (permalink / raw)
  To: stardiviner; +Cc: Roland Everaert, Org Mode

On Tuesday, 23 Oct 2018 at 19:48, stardiviner wrote:
> This is really helpful for me, I use smartparens before, but it is a
> little heavy. So I disabled it. I found your solution is simple and
> fast. I modified a little:

+1

I gave up long ago on smartparens but skeleton seems to work well.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-783-g97fac4

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-23 11:48       ` stardiviner
  2018-10-23 13:07         ` Eric S Fraga
@ 2018-10-24 10:38         ` Roland Everaert
  2018-10-24 10:45           ` Eric S Fraga
  1 sibling, 1 reply; 16+ messages in thread
From: Roland Everaert @ 2018-10-24 10:38 UTC (permalink / raw)
  To: numbchild; +Cc: Org Mode


I will borrow your config for the emphasis symbols, but for all the
paren-related symbols, I will keep the global mapping, so it will still
work when writing codes and the like ;)

Pleased to see it was helpful. The funny thing is that I use that config
for, maybe, 10 years and never think about changing it.

stardiviner writes:

> Roland Everaert <reveatwork@gmail.com> writes:
>
>> Hi,
>>
>> I use the following configuration:
>>
>>     ;;;;;;;;;;;;;;;; parenthèses, accolades et brackets ;;;;;;
>>     (setq skeleton-pair t)
>>     (global-set-key "[" 'skeleton-pair-insert-maybe)
>>     (global-set-key "{" 'skeleton-pair-insert-maybe)
>>     (global-set-key "(" 'skeleton-pair-insert-maybe)
>>     (global-set-key "\"" 'skeleton-pair-insert-maybe)
>>     (global-set-key "'" 'skeleton-pair-insert-maybe)
>>
>> This will only close the defined characters.
>>
>>
>> Hope this will help.
>>
>> Roland.
>>
>
> This is really helpful for me, I use smartparens before, but it is a little heavy. So I disabled it. I found your solution is simple and fast. I modified a little:
>
> #+begin_src emacs-lisp
> (require 'skeleton)
> (setq skeleton-pair t)
>
> (define-key org-mode-map (kbd "~") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "=") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "*") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "+") 'skeleton-pair-insert-maybe)
>
> (define-key org-mode-map (kbd "[") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "{") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "(") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "\"") 'skeleton-pair-insert-maybe)
> (define-key org-mode-map (kbd "'") 'skeleton-pair-insert-maybe)
> #+end_src


-- 
Luke, use the FOSS

Sent from Emacs

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-24 10:38         ` Roland Everaert
@ 2018-10-24 10:45           ` Eric S Fraga
  2018-10-24 21:24             ` Tim Cross
  0 siblings, 1 reply; 16+ messages in thread
From: Eric S Fraga @ 2018-10-24 10:45 UTC (permalink / raw)
  To: Roland Everaert; +Cc: Org Mode

On Wednesday, 24 Oct 2018 at 12:38, Roland Everaert wrote:
> Pleased to see it was helpful. The funny thing is that I use that config
> for, maybe, 10 years and never think about changing it.

I've been using emacs for well over 30 years now.  You would not believe the crud that has built up in my config files... ;-) :Q

Mind you, with org, I have started rationalizing the config files but it's a time consuming task and the adage of "if it ain't broke, don't fix it" has power...

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-783-g97fac4

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-23 13:07         ` Eric S Fraga
@ 2018-10-24 13:12           ` Matt Price
  2018-10-24 14:15             ` Eric S Fraga
  0 siblings, 1 reply; 16+ messages in thread
From: Matt Price @ 2018-10-24 13:12 UTC (permalink / raw)
  To: numbchild, reveatwork, Org Mode

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

Eric, you seem to be replying to an email that I sometimes don't have -- I
would love to see what @stardiviner wrote, do you stil lhave the email?

On Tue, Oct 23, 2018 at 9:12 AM Eric S Fraga <esflists@gmail.com> wrote:

> On Tuesday, 23 Oct 2018 at 19:48, stardiviner wrote:
> > This is really helpful for me, I use smartparens before, but it is a
> > little heavy. So I disabled it. I found your solution is simple and
> > fast. I modified a little:
>
> +1
>
> I gave up long ago on smartparens but skeleton seems to work well.
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-783-g97fac4
>
>

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

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-24 13:12           ` Matt Price
@ 2018-10-24 14:15             ` Eric S Fraga
  0 siblings, 0 replies; 16+ messages in thread
From: Eric S Fraga @ 2018-10-24 14:15 UTC (permalink / raw)
  To: Matt Price; +Cc: reveatwork, Org Mode

On Wednesday, 24 Oct 2018 at 09:12, Matt Price wrote:
> Eric, you seem to be replying to an email that I sometimes don't have -- I
> would love to see what @stardiviner wrote, do you stil lhave the email?

I've forwarded that email to you but it's strange that you missed it as
it was sent to the org mode mailing list.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-783-g97fac4

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-24 10:45           ` Eric S Fraga
@ 2018-10-24 21:24             ` Tim Cross
  2018-10-25 15:07               ` Eric S Fraga
  0 siblings, 1 reply; 16+ messages in thread
From: Tim Cross @ 2018-10-24 21:24 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: Roland Everaert, Org Mode


Eric S Fraga <esflists@gmail.com> writes:

> On Wednesday, 24 Oct 2018 at 12:38, Roland Everaert wrote:
>> Pleased to see it was helpful. The funny thing is that I use that config
>> for, maybe, 10 years and never think about changing it.
>
> I've been using emacs for well over 30 years now.  You would not believe the crud that has built up in my config files... ;-) :Q
>
> Mind you, with org, I have started rationalizing the config files but it's a time consuming task and the adage of "if it ain't broke, don't fix it" has power...

+1

Likewise, started with Emacs 19 and I still have some code which I added
back then in my init!

I went through the pain of cleaning up my init file some time ago when I
moved to make better use of 'use-package'. Have to say that while things
were not 'broken' before my cleanup, they are certainly working better
now and my init is much smaller.

What I found was that a lot of what was in my init file was simply no
longer required as similar (often superior) functionality has crept into
the main Emacs distribution - all I needed to do was remove my code and
turn the feature on.

The two big benefits from the clean up have been much faster start up
(something which never really bothered me as I run emacs for weeks
without re-starting anyway) and far more predictable behaviour when I
try out or add a new mode (I often found my custom tweaks would not
always work well with new modes etc).

Org is extremely useful in this process. Create an org file and put all
your existing init in there as source blocks so that you can reproduce
your setup using tangle. Then create a new-init.org file and just add
the stuff you must have i.e. email config, essential modes etc. Then you
can switch between old and new setups using tangle to generate new
init.el file. When you have time, start with the new-init version and
start adding/tweaking to get the behaviour you want. Rather than just
copy across your old setup, check to see what is available in core - if
your like me, you will find lots of we use to tweak in code is now part
of core emacs and all you need to do is turn it on. At some point, you
will find you stay in your new init file and no longer need to revert to
the old version. You will likely find lots of stuff never gets
migrated. 

It really is worth the time and effort.

Tim

-- 
Tim Cross

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-24 21:24             ` Tim Cross
@ 2018-10-25 15:07               ` Eric S Fraga
  2018-10-25 22:57                 ` Samuel Wales
  0 siblings, 1 reply; 16+ messages in thread
From: Eric S Fraga @ 2018-10-25 15:07 UTC (permalink / raw)
  To: Tim Cross; +Cc: Roland Everaert, Org Mode

On Thursday, 25 Oct 2018 at 08:24, Tim Cross wrote:
> Likewise, started with Emacs 19 and I still have some code which I added
> back then in my init!

[...]

> The two big benefits from the clean up have been much faster start up
> (something which never really bothered me as I run emacs for weeks
> without re-starting anyway) and far more predictable behaviour when I
> try out or add a new mode (I often found my custom tweaks would not
> always work well with new modes etc).

The second of these is indeed a benefit of cleaning up initialization
files.  I have been doing so, in any case, just at a slower pace than I
should.  I actually have been doing exactly what you suggest: using org
and tangling.
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-894-gf79545

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-25 15:07               ` Eric S Fraga
@ 2018-10-25 22:57                 ` Samuel Wales
  2018-10-25 22:59                   ` Samuel Wales
                                     ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Samuel Wales @ 2018-10-25 22:57 UTC (permalink / raw)
  To: Tim Cross, Roland Everaert, Org Mode

can either of you give examples of code or settings that you had that
made behavior of new modes unpredictable because emacs started
supporting the behavior you made the code or settings for?


On 10/25/18, Eric S Fraga <esflists@gmail.com> wrote:
> On Thursday, 25 Oct 2018 at 08:24, Tim Cross wrote:
>> Likewise, started with Emacs 19 and I still have some code which I added
>> back then in my init!
>
> [...]
>
>> The two big benefits from the clean up have been much faster start up
>> (something which never really bothered me as I run emacs for weeks
>> without re-starting anyway) and far more predictable behaviour when I
>> try out or add a new mode (I often found my custom tweaks would not
>> always work well with new modes etc).
>
> The second of these is indeed a benefit of cleaning up initialization
> files.  I have been doing so, in any case, just at a slower pace than I
> should.  I actually have been doing exactly what you suggest: using org
> and tangling.
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.1.13-894-gf79545
>
>


-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-25 22:57                 ` Samuel Wales
@ 2018-10-25 22:59                   ` Samuel Wales
  2018-10-26  9:23                   ` Eric S Fraga
  2018-10-26 21:45                   ` Tim Cross
  2 siblings, 0 replies; 16+ messages in thread
From: Samuel Wales @ 2018-10-25 22:59 UTC (permalink / raw)
  To: Tim Cross, Roland Everaert, Org Mode

oh i got that slightly wrong.  i meant can you give exmaples of what
yoa re saying.

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-25 22:57                 ` Samuel Wales
  2018-10-25 22:59                   ` Samuel Wales
@ 2018-10-26  9:23                   ` Eric S Fraga
  2018-10-26 21:45                   ` Tim Cross
  2 siblings, 0 replies; 16+ messages in thread
From: Eric S Fraga @ 2018-10-26  9:23 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Tim Cross, Org Mode, Roland Everaert

On Thursday, 25 Oct 2018 at 15:57, Samuel Wales wrote:
> can either of you give examples of code or settings that you had that
> made behavior of new modes unpredictable because emacs started
> supporting the behavior you made the code or settings for?

In my case, mostly incompatible bindings of keys, e.g. the tab key, especially in the context of auto-completion mechanisms and auto-expansion (e.g. yasnippet).  It's not so much unpredictable behaviour as wrong behaviour due to settings stepping on the toes of subsequently installed packages.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.11-620-ga548e4

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

* Re: electric-pair, autopair, smartparens, etc in org-mode
  2018-10-25 22:57                 ` Samuel Wales
  2018-10-25 22:59                   ` Samuel Wales
  2018-10-26  9:23                   ` Eric S Fraga
@ 2018-10-26 21:45                   ` Tim Cross
  2 siblings, 0 replies; 16+ messages in thread
From: Tim Cross @ 2018-10-26 21:45 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Roland Everaert, Org Mode


Samuel Wales <samologist@gmail.com> writes:

> can either of you give examples of code or settings that you had that
> made behavior of new modes unpredictable because emacs started
> supporting the behavior you made the code or settings for?
>

It is difficult to remember now as it was some time ago that I cleaned
up my init and got rid of much of my old stuff. Areas I do remember
include

- Key bindings. This is probably the most common. You would enable a new
  Emacs feature only to find you had conflicts with key bindings. In the
  best case, some new features couldn't be easily accessed. In the worst
  case, a new feature would create unexpected behaviour. The hard part
  was often in deciding whether to try and change the bindings or change
  my finger memory.

- Hooks. This was probably the second most common problem. A new feature
  would add to a hook where I had a similar feature also on that
  hook. As a result, both would run and result in unexpected outcomes.

- Convenience functions for selecting files, buffers and windows,
  working with sets of files (i.e. projects), My setup predated ido, and
  packages like yasnippets, projectile and company mode which I now use. In many
  cases, my own tweaks were OK, but not as robust or feature rich as
  standard packages that were added to Emacs over releases which
  provided similar functionality.

- As my init had grown in a rather 'organic' manner - bits added as I
  needed them, there was a lack of consistency or structure to my
  configuration. As a result, often when I tried a new feature, there
  would be parts of my init I would forget to remove/disable that would
  conflict with that feature. As I used autoloads quite a bit, things
  would also be a little inconsistent as conflicts could be dependent on
  the order things got loaded and that order could be affected by what I
  did in a specific session.

- One area I do remember was with respect to handling of PDF, HTML and
  other document types. I had a lot of config which would automatically
  convert many of these types to plain text to make them easy to work
  with inside emacs. As modes like doc-view, eww etc were added. I
  recall at times, conflicts would occur. I remember at one point, what
  behaviour I would experience when opening a PDF would depend on what
  mode had been loaded. If doc-view was already loaded, I would see the
  PDF rendered using doc-view - if my code was already loaded, I would
  see a plain text version. Often, the result would not be the one I
  wanted. I now no longer have all that code in my init and leave such
  things to Emacs.

In my case, much of my elisp config was pretty rough - I did as little
as necessary to get the behaviour I wanted. It was often poorly tested,
lacked sufficient error checking, was inconsistent and overall rough -
it did the job. However, this did mean it often did not play well with
others. For ages, I simply didn't bother looking at new features and
modes unless I came across a new requirement e.g. learning a new
programming language, working with a new system etc. My init also had
large amounts of code borrowed with pride (aka stolen) from newsgroup
postings, web sites, mail lists and various elisp repositories. As I
tend not to bother compiling my init, you would not necessary be aware
of obsolete and deprecated functions used by this code. The lack of any
namespace for packages also meant name conflicts were sometimes the
cause of weird bugs etc. Overall, things were 'fragile' and you would
avoid making changes as much as possible.  

I was frequently surprised when I decided it was time to cleanup my init at
various improvements and enhancements that had been added to Emacs. This
is partially a result of the conservative approach Emacs tends to adopt
- a good approach as it means you can usually upgrade to a new version
and not end up spending hours fixing things just to get back to
work. However, the downside is that it also means you may not even be
aware of or benefit from some improvements.

The positive is that now I have a nicely structured and documented org
file with my init and making changes is easy. Actually, I have multiple
configs - a standard working config, a 'new features' config where I try
out new packages etc, a very simple minimal config I use for
testing/debugging problems etc. I have a simple shell script which I can
run and pass it an org file name which will generate a new init.el and I
keep it all in git. At this time, I'm probably happier with my Emacs
setup than during any period in the last 25 years. 

Tim



Tim Cross

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

end of thread, other threads:[~2018-10-26 21:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-21  0:36 electric-pair, autopair, smartparens, etc in org-mode Matt Price
2018-10-21  7:28 ` Nicolas Goaziou
2018-10-21 16:43   ` Matt Price
2018-10-23  7:58     ` Roland Everaert
2018-10-23 11:48       ` stardiviner
2018-10-23 13:07         ` Eric S Fraga
2018-10-24 13:12           ` Matt Price
2018-10-24 14:15             ` Eric S Fraga
2018-10-24 10:38         ` Roland Everaert
2018-10-24 10:45           ` Eric S Fraga
2018-10-24 21:24             ` Tim Cross
2018-10-25 15:07               ` Eric S Fraga
2018-10-25 22:57                 ` Samuel Wales
2018-10-25 22:59                   ` Samuel Wales
2018-10-26  9:23                   ` Eric S Fraga
2018-10-26 21:45                   ` Tim Cross

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).