pmarinov / clean-aindent-mode

Emacs extension for simple indent and unindent
Other
32 stars 7 forks source link

Not available in MELPA. #2

Closed ryantm closed 10 years ago

ryantm commented 10 years ago

This code is not available in MELPA. To get it into MELPA, we need to write a MELPA recipe and submit it as a pull request.

I looked at the code and noticed some issues that might block MELPA acceptance. Some functions are prefixed by bsunindent. It looks like this package should be named clean-aindent, which should be the prefix for all of the definitions.

pmarinov commented 10 years ago

Is this requirement verified programmatically upon submission? If yes, then I can see how to rename them. Just that the names will become really unwieldy.

It would be nice for it to be on MELPA. I haven't had the time to research what needs to be done. Apart from the naming uniformity is there anything more that might be needed?

pmarinov commented 10 years ago

But, I use MELPA myself, so I guess it makes sense to submit "clean-aindent" to it. I will take the time tonight to see how to rename the functions and what is needed for the submission recipe.

ryantm commented 10 years ago

There isn't a programmatic verification, they just look over your package for various naming style conventions before they accept the recipe pull request. They don't want to have packages with conflicting names in the repository.

ryantm commented 10 years ago

I'll look over your package more carefully in an hour or so to try to help you out. I can do the MELPA recipe if you want me to. It's easy.

ryantm commented 10 years ago

We should probably convert this into a global minor-mode.

pmarinov commented 10 years ago

I just committed the renaming of the functions so that they can all be in the same namespace (prefix).

I'd gladly accept any help (the recipe) for the submission to MELPA.

On the global minor-mode, let me study the implications. In general I'm positive about the conversion.

ryantm commented 10 years ago

I wrote the recipe here: https://github.com/ryantm/melpa/commit/590612326b62cc4bddb385fb93b050332b200493

It anticipates renaming the package and repository to clean-adindent-mode.

ryantm commented 10 years ago

A global minor mode can be customized to be on, and it will let you have a keymapping, so you do not have to overwrite the RET and M-DEL key mappings like you are now in clean-aindent-init.

ryantm commented 10 years ago

Like this: https://github.com/ryantm/clean-aindent/commit/9934b476ec382fd65b8a0947d2ec0911ec75a1e8

pmarinov commented 10 years ago

Thank you very much for the help. Tonight I will start working to implement the changes based on your 2 examples (minor mode, MELPA recipe).

I understand better now that distributing it as a minor mode is the preferred method for the type of extension clean-aindent is.

pmarinov commented 10 years ago

I hit a problem.

If clean-aindent-mode is declared as global then its keymap of "RET" conflicts with what is assigned for editing in the minibuffer. After the mode is enabled editing the minibuffer stops working.

Do you know if there is a way to have a mode that is enabled only outside the minibuffer?

I'm working to figure this out. Alternatively, clean-aindent-mode can be non-global, although, that is a step back from the current setup which works well everywhere.

ryantm commented 10 years ago

I'm not sure how best to handle that. Maybe you could disable it with a minibuffer-setup-hook and exit-hook?

http://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Misc.html

pmarinov commented 10 years ago

The solution is to use conditional keymaps (emulation-mode-map-alists). This is a method used by minor-modes that need many keymaps which are active depending on certain condition. In case of clean-aindent-mode there is only one keymap and its condition is re-evaluated to nil when user enters minibuffer.

The example I'm following is the implementation of the cua-mode.

pmarinov commented 10 years ago

I couldn't make conditional keymaps for "RET" work well. Basically the detection portion gets bogged down in detecting stuff like minibuffer, read-only, or non-edit buffers like dired.

The simplest solution is to have the keys defined as global-set-key at load time (the current implementation), this gives them lower priority than key-bindings of the modes. Any need for detection is eliminated.

The only purpose of the mode then is to only be on/off so that the hooked functions are toggled into operation or remain dormant.

I will test this new setup for a day or two and then check it in.

ryantm commented 10 years ago

It's in MELPA now.

pmarinov commented 10 years ago

Thanks again. It is a great feeling to have the submission to MELPA approved! :smile:

I had to change a bit the setup. I was wondering do you see any trouble setting it up now via MELPA? I need to update the README to match the installation instructions I put in the .el file.

I will also work on the emacswiki page, some of these days.