Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

add emacs abbrv support to the yankpad? #31

Closed zeltak closed 6 years ago

zeltak commented 6 years ago

final question for the day ;-)

as i said yankpad is my most used emacs package and im trying to do as much as i can through it as i find its so great in organizing all my snippets and text entries. One thins i always use alongside snippets in emacs is a misc. abbrv file that i load in each session:

(load "/home/zeltak/.emacs.d/abbrv/misc_abbrv.txt")

this file has something like this inside

(define-abbrev-table 'global-abbrev-table
  '(
    ("8bash" "#!/bin/bash" nil 0)
    ("8emi" "ikloog@gmail.com" nil 0)
    ("8emu" "ikloog@bgu.ac.il" nil 0)
    ("8emz" "zeltak@gmail.com" nil 0)
    ("8fl" "file:~/" nil 0)
    ("8rs" "#+REVEAL: split" nil 0)
    ("8rl" "#+ATTR_HTML: :style text-align:left" nil 0)
    ("8rt" "#+ATTR_HTML: :style color:green\n*lets try it on your computer!*")
    ("8rc" "#+ATTR_HTML: :style color:red" nil 0)
    ("8rf" "#+OPTIONS: reveal_single_file:t" nil 0)
    ("6z" "/home/zeltak/ZH_tmp/" nil 0)
    ("8wr" "@Warning@" nil 0)
    ("8c" "#-------------->" nil 0)
    ("Note" "$Note$" nil 0)
    ("Tip" "%Tip%" nil 0)
    ("Warning" "@Warning@" nil 0)
    ("7su" "ssh:/uni:/" nil 0)
))

was wondering if i can manage this within yankpad, i know there is overlap and maybe i dont fully understand how abbrv should be used, but wondering what your thoughts are on this?

thx!

z

Kungsgeten commented 6 years ago

I do not quite understand what you wish to do. It sounds like you want snippets which can be expanded with the space key (I don't use abbrev-mode myself, but I guess thats what it does)?

zeltak commented 6 years ago

Hi again

sorry for not explaining correctly :)

i guess that yes i want to use my built in abbrev-mode expansions (which indeed use the space key to expand) but manage the actual abbrv file text inside my yankpad. does that make any sense ? :)

so for example instead of adding my individual abbrv file like currently

** personal abbriviations
:PROPERTIES:
:ID:       e09fad19-96c8-4670-8769-29618e50f0d1
:END:
*** new collected abbrv
:PROPERTIES:
:ID:       8b86b856-59b2-402e-ac9d-7cb7c030a145
:END:
to quickly peak at the personal file look here:
file:/home/zeltak/.emacs.d/abbrv/personal_abbrv.txt
to set 
#+BEGIN_SRC emacs-lisp :results none
(setq abbrev-file-name "/home/zeltak/.emacs.d/abbrv/personal_abbrv.txt")
#+END_SRC
to autoload it 
#+BEGIN_SRC emacs-lisp :results none
(load "/home/zeltak/.emacs.d/abbrv/personal_abbrv.txt")
#+END_SRC
*** loads a huge common abbreviations file
:PROPERTIES:
:ID:       a7f03b5c-7e74-4a66-8f56-20bb3bf2b1d3
:END:
file:/home/zeltak/.emacs.d/abbrv/common_abbrv.txt
#+BEGIN_SRC emacs-lisp :results none
(load "/home/zeltak/.emacs.d/abbrv/common_abbrv.txt")
#+END_SRC
*** misc abbrv file (general stuff to quick add)
:PROPERTIES:
:ID:       018d14e4-b169-4c31-8eb2-2588d2b31661
:END:
file:/home/zeltak/.emacs.d/abbrv/misc_abbrv.txt
#+BEGIN_SRC emacs-lisp :results none
(load "/home/zeltak/.emacs.d/abbrv/misc_abbrv.txt")

i would just store and edit them in yankpad. the expansions would still be handed via the emacs internal abbrev-mode commands. sorta like the complementary use of yasnippet?

if this dosent make sense i understand, just a thought i had :)

best

Z

Kungsgeten commented 6 years ago

It's now possible to use yankpad to add definitions to abbrev-mode. You need to set the variable yankpad-descriptive-list-treatment to 'abbrev. Then abbrevs can be added as descriptive lists inside categories (see the README). Another new features is the :global: tag which can be added to categories, so that their snippets are always available. This might be useful if you want global abbrevs.

zeltak commented 6 years ago

thx so much!

i seem to be missing something since i cant get it to work

i have this in my yankpad conf

(setq yankpad-descriptive-list-treatment "abbrev") 

then i added this to my yankpad

* abbrv mode                                                         :global:
  - name :: zeltak brisbane 

when i type name it dosent get expanded to zeltak brisbane after i press enter as in emacs other abbrevs. isnt that the way it should work? am i missing something and is my config correct?

thx!

Z

Kungsgeten commented 6 years ago

It should be 'abbrev (a symbol) not "abbrev" (a string).

On Sat, Mar 31, 2018, 16:59 zeltak notifications@github.com wrote:

thx so much!

i seem to be missing something since i cant get it to work

i have this in my yankpad conf

(setq yankpad-descriptive-list-treatment "abbrev")

then i added this to my yankpad

  • abbrv mode :global:
    • name :: zeltak brisbane

when i type name it dosent get expanded to zeltak brisbane after i press enter as in emacs other abbrevs. isnt that the way it should work? am i missing something and is my config correct?

thx!

Z

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/Kungsgeten/yankpad/issues/31#issuecomment-377698900, or mute the thread https://github.com/notifications/unsubscribe-auth/ADysufrhbZ3ixSeZfBiJ-aSjelqa1JE3ks5tj5m9gaJpZM4Srmio .

zeltak commented 6 years ago

thx!

so i have this now

(setq yankpad-descriptive-list-treatment 'abbrev ) 

and i confirmed it

yankpad-descriptive-list-treatment is a variable defined in `yankpad.el'.
Its value is abbrev

yet still cant get name to expand to zeltak brisbane

anything else i should configure/check?

Kungsgeten commented 6 years ago

I think it should work. It might be the case that you have to set a category first, so please try yankpad-set-category. You could also try yankpad-reload. Also make sure that you've turned on abbrev-mode.

zeltak commented 6 years ago

Hi again and happy Easter ;-)

first i did verify im in abbrev-mode and also that other non yankpad abbrevs do indeed work

I have reloaded yankpad but a strange thing is (and this maybe a clue to the issue) is that the abbrev section does not appear in the select category! ive even literally copied your section

* Category 2

  Descriptive lists at the top-level of a category will be treated as snippets.
  You can set them to be treated as =abbrev-mode= abbrevs instead, by setting
  =yankpad-descriptive-list-treatment= to abbrev.

  - name :: Erik Sjöstrand
  - key :: Typing "key" followed by `yankpad-expand' will insert this snippet.

reloaded and still there is now category 2 in yankpad-set-category

could that be the issue

thx!

Z

Kungsgeten commented 6 years ago

Perhaps you have a different yankpad-category-level?

On Sun, Apr 1, 2018, 06:27 zeltak notifications@github.com wrote:

Hi again and happy Easter ;-)

first i did verify im in abbrev-mode and also that other non yankpad abbrevs do indeed work

I have reloaded yankpad but a strange thing is (and this maybe a clue to the issue) is that the abbrev section does not appear in the select category! ive even literally copied your section

  • Category 2

    Descriptive lists at the top-level of a category will be treated as snippets. You can set them to be treated as =abbrev-mode= abbrevs instead, by setting =yankpad-descriptive-list-treatment= to abbrev.

    • name :: Erik Sjöstrand
    • key :: Typing "key" followed by `yankpad-expand' will insert this snippet.

reloaded and still there is now category 2 in yankpad-set-category

could that be the issue

thx!

Z

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/Kungsgeten/yankpad/issues/31#issuecomment-377742842, or mute the thread https://github.com/notifications/unsubscribe-auth/ADysucQAMTM6DSDJoknkrHExujoIbxkXks5tkFcZgaJpZM4Srmio .

zeltak commented 6 years ago

yes you were right :blush: i changed the category level and it works now as advertised :D

thx so much again for your epic work, seriously its my #1 package i the emacs universe ;-)

best

Z