-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set custom shortcuts #447
Comments
Hmm... What's your question? :p (define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-schemes :initform (list :emacs-map *my-keymap*
:vi-normal *my-keymap*))))
(defun my-buffer-defaults (buffer)
(dolist (mode '(proxy-mode my-mode)) ;; <= Any mode that you want by default!
(pushnew mode (default-modes buffer))))
(defun my-interface-defaults ()
(hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
#'my-buffer-defaults)) Hope that helps! |
This line: raised the error:
is there some (make-keymap) ? If yes, it would be good to add that to the documentation. Or did I miss something else? |
Indeed you can create a keymap as follows:
```lisp
(defvar *my-keymap* (make-keymap)
"My keymap.")
```
If yes, it would be good to add that to the documentation.
Will do, thanks for the suggestion!
|
Well thanks now it don't throws a error but it doesn't do what it supposed to do, none of the shortcuts works. And it doesn't recognize the 2 history functions even in the console they are a choice.
Do I have to write wrapper functions around that functions which is what I see in the extensions.org documentation file Ideally you could post a minimal init file that works on your side? with that shortcuts? Before we go another 5 times forth and back? |
I get the same error as you when I try to add the same keybinding. Looks like Try this:
|
Indeed, the history commands belong to web mode.
We should display it in the `execute-command' minibuffer.
Only bindings of active modes are caught. So if web-mode is not active,
the history-forwards command won't be available either.
Hope that helps! :)
|
Well now history function works btw here on github always the star "*" get suppressed around my-keymap apperently sucks when you poste code and it hides parts of it, don't get how that can happen... But the other commands seem to work, too. But history is buggy:
Should I open a new bug for that? Is that maybe some internet forwarding this sites do and the browser registers as 2 different websites when in fact it's the same? |
Stefan Huchler <notifications@github.com> writes:
Well now history function works btw here on github always the star "*"
get suppressed around my-keymap apperently sucks when you poste code
and it hides parts of it, don't get how that can happen...
Sorry, didn't get that. Can you rephrase?
But the other commands seem to work, too. But history is buggy should I open a different bugreport for that?
1. after opening a url back brings me not back to the start page. Even
if I click on a link on the startpage back don't brings me back. So
the startpage is not in the history can be seen as feature not sure
feels a bit odd to me.
Indeed, the start page is not in the history. It's intentional, but I
see no reason it shouldn't, so I guess we can call this a bug and we
should fix this.
2. very strange behaviour that is different on differenent sides: so
if I go to google or github and I press history back it reloads the
site and does the resizing I set up in the hook (hidpi) which is odd
if it has only 1 site in the history forward and backward should not
reload the page it should just do nothing right?
Another bug! :p Thanks for catching this!
The buffer history implementation was just rewritten, so it's a bit
rough on the edge, sorry about that.
But when I open heise.de (a german IT news site) it does ignore
history back/forth and not reloads the site?
I can't reproduce. Can you provide a precise recipe (in a new issue)?
Should I open a new bug for that?
Please do! :)
|
K I checked again the handling of the star/multiply sign. In my original post I posted the source as normal text not as source therefor it removed the * around the my-keymap strings when I saw your code and that I had to add the * around it to make it work:
I assumed you also did have the * around the my-keymap and it got stripped from it, if you mark it as source it don't read it as markup, you just forgot them. About the heise.de site besides the point that the startpage is not in the history it works fine it's just the google/github sites that don't work correctly so it makes no sense to report a bug because 1 site works correct I think? It's just odd to me why it site specific works differently... The history is a bit rough but it's not very crucial to me at the point I need "darkmode" before I can use the browser productive here and you said that that this part is just rewritten. Maybe it's better to wait 1 release before I write a bugreport on that part? I mean if I go on heise.de press a article, I can go back to the main page over history-back but forward then reloads the main page... that seems to me not very hard to reproduce right? :-) |
Yes, please open a new issue and list all the problems you've noticed
with the history, with precise recipes if possible.
Regarding the `*my-keymap*` with or without stars: the stars are purely
conventional, they are part of the symbol name like any other character.
They are use in Common Lisp to denote global variable.
You don't have to use them, but you've got to be consistent with your
use of the name throughout the configuration file.
|
Is this the correct MWE of overriding the default keybinding? (in-package :next)
(defvar *my-keymap* (make-keymap)
"My keymap.")
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-schemes :initform (list :emacs-map *my-keymap*
:vi-normal *my-keymap*))))
(defun my-buffer-defaults (buffer)
(dolist (mode '(proxy-mode my-mode)) ;; <= Any mode that you want by default!
(pushnew mode (default-modes buffer))))
(defun my-interface-defaults ()
(hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
#'my-buffer-defaults))
(define-key :keymap *my-keymap* "s-m" #'switch-buffer)
Did I miss something? |
You are not installing the new interface defaults ;)
You just miss this line:
```
(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)
```
By the way, on master we've got a new (experimental) configuration
style, the CLOS-style config.
The `my-mode` keymap is mostly useful to create _global_ bindings and
override other bindings. If you want to customize the bindings of a
specific mode, you can create a subclass of the mode, then use it
instead of the original.
He follow the CLOS-style way to add my-mode to the list of mode for all
buffers:
```
(defclass my-buffer (buffer)
((default-modes :initform (append
'(my-mode vi-normal-mode
my-blocker-mode
proxy-mode)
(get-default 'buffer 'default-modes)))
(load-hook :initform (list #'old-reddit-handler
#'auto-proxy-handler))))
(setf *buffer-class* 'my-buffer)
```
In a similar fashion, you can create a new mode with new bindings and
call
```
(setf *WHATEVER-MODE-class* 'my-WHATEVER-MODE)
```
(Of course, you need to replace WHATEVER-MODE with what is appropriate).
|
Where to add that line? is it here? + (hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)
(define-key :keymap *my-keymap* "C-x m" #'switch-buffer) If yes, it didn't manage to work either. I've tried the key to "C-x m", "s-m", "m". Am I missing something? |
Sorry, I didn't spot the typo at first: it's `:emacs`, not `:emacs-map`.
I've fixed the documentation accordingly.
To sum up, your init.lisp:
```
(in-package :next-user)
(defvar *my-keymap* (make-keymap)
"My keymap.")
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-schemes :initform (list :emacs *my-keymap*
:vi-normal *my-keymap*))))
(defun my-buffer-defaults (buffer)
(dolist (mode '(proxy-mode my-mode)) ;; <= Any mode that you want by default!
(pushnew mode (default-modes buffer))))
(defun my-interface-defaults ()
(hooks:add-to-hook (hooks:object-hook *interface* 'buffer-make-hook)
#'my-buffer-defaults))
(define-key :keymap *my-keymap* "s-m" #'switch-buffer)
(hooks:add-to-hook '*after-init-hook* #'my-interface-defaults)
```
It'd be nice to spot this kind of errors.
Maybe declare a list of known keymap schemes globally?
|
Your latest snippets works for me. So you changed Thank you :) |
The :next-user package is not mandatory, but recommended.
Your actualy issue was due to a typo in the doc: it's `:emacs`, not `:emacs-map`.
|
Okay thanks, everything sets. I am unable to use Thank you. |
If the problem is solved, may we close this issue? |
@jmercouris I am not the author, :) |
I think we can close this now. Feel free to reopen if there is anything else. |
Hi! I am trying to set custom keybindings for vi-mode. However the code in the documentation is not clear to me/does not work. For example if I use the init file as given in this comment above then I get the following error message:
line 3 is the Is this a bug (it means the make-keymap requires an argument)? Thanks for your help... (and the beautiful browser!) |
Thank you for reporting, there was a documentation bug indeed! Fixed in commit 14bf6c4.
Minimal example: (define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-scheme :initform
(define-scheme "my-scheme"
scheme:cua
(list
"C-f" 'history-forwards
"C-b" 'history-backwards)
scheme:emacs
(list ...)))))
(define-configuration buffer
((default-modes (append '(my-mode) %slot-default)))) |
Thanks for looking into it. Unfortunately I do not understand much yet of common-lisp or the next documentation. When I try the new code from the documentation, for example the following part
then I still get an error:
I guess maybe the
Unfortunately as I do not know common-lisp (nor CLOS) yet, and because I don't know further introspection options yet, I can not provide much more/useful information... |
Can you please post the entirety of your init file so that we may better assist you? Thanks! |
Also you are correct, it should be:
|
Hi thanks for looking into it. Because things were not working I removed all other code from the init file so that it contained the code I posted in my last comment above exclusively (where because of your last comment I now added that extra parenthesis). So the following is currently the full code in my init file:
When I try to run next then I get the error message (the second one because now I added the parenthesis) that I posted in my last comment above |
I've tried your snippet, it works for me.
From
From the output you've pasted, you're using commit 73ab116 which is 1
month old. Try again against latest master, it should work.
|
@Ambrevar This snippet doesn't work anymore. I am getting this error: $ ./next
Next version 1.5.0
Loading configuration from #P"/home/john/.config/next/init.lisp"...
Error: we could not load the init file
READ error during LOAD:
Package HOOKS does not exist.
Line: 36, Column: 20
Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/john/.config/next/init.lisp" {1004C585F3}> trying the snippet from the docs also didn't work: $ ./next
Next version 1.5.0
Loading configuration from #P"/home/john/.config/next/init.lisp"...
While evaluating the form starting at line 55, column 0
of #P"/home/john/.config/next/init.lisp":
Error: we could not load the init file
invalid number of arguments: 1 Any breaking changes or am I missing something? |
This topic is heavily outdated. In the newest Next, run the |
Let me know if you need help with a particular config. |
@Ambrevar I wanted to try a few days ago with the newest version, but when I click the Download link in the git README then I got a "502 Bad Gateway" error, I assumed it would get fixed and today I wanted to try again but I still get the same error, despite #744 was closed yesterday because the Download page was/should be available again. Also as recommended in #744, I tried to build from source but I get a build error. I saved the output of the make process in the following file: |
@Ambrevar Thanks for the tip. Unfortunately tutorial command only availiable at 2.0. I still having problem running next with guix from source, Any hints? |
I've tried to compile the tutorial to to html manually using I think we have typo in I peak your config and covert mine to: (in-package :next-user)
(defvar *my-keymap* (make-keymap "my-map")
"Keymap for `my-mode'.")
(define-key *my-keymap*
"C-f" 'history-forwards
"C-b" 'history-backwards)
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-scheme :initform (keymap:make-scheme
scheme:cua *my-keymap*
scheme:emacs *my-keymap*
scheme:vi-normal *my-keymap*))))
(define-configuration buffer
((default-modes (append '(my-mode) %slot-default)))) but still have the same error: $ ./next
Next version 1.5.0
Loading configuration from #P"/home/user/.config/next/init.lisp"...
While evaluating the form starting at line 3, column 0
of #P"/home/user/.config/next/init.lisp":
Error: we could not load the init file
invalid number of arguments: 1 |
Daniel Nicolai <notifications@github.com> writes:
@Ambrevar I wanted to try a few days ago with the newest version, but when I click the Download link in the git README then I got a "502 Bad Gateway" error, I assumed it would get fixed and today I wanted to try again but I still get the same error, despite #744 was closed yesterday because the Download page was/should be available again.
Which link?
https://next.atlas.engineer/download is working for me, but if you want
the newest version you should go for master on GitHub for now.
Also as recommended in #744, I tried to build from source but I get a build error. I saved the output of the make process in the following file:
[make_all.log](https://github.com/atlas-engineer/next/files/4664446/make_all.log)
You are probably using an outdated Quicklisp.
Can you open a new issue and detail how you've built Next?
(Commands you've entered and the results you got.)
|
@azzamsa: Good catch!
I've fixed the typo in 4ba0a93.
About your error: the new config style only works on master.
If you want to consult documentation for 1.5, have a look at
https://github.com/atlas-engineer/next/blob/1.5.0/documents/MANUAL.org
|
@Ambrevar I indeed meant that download link which was not working when I created my last comment (and also the previous time), but it is working now here too. Actually to get build instructions for next, I tried to access the developer manual page but that also gave error 502 at that time. Therefore I followed the instructions in the INSTALL file in the repo. However, I had two copies of the repo, one in my ~/git directory and another one in my ~/common-lisp directory and I had forgotten about the latter one. So I was following the instruction in the repo in my ~/git directory. Now that I could access the Developer Manual again, I found that I should build from the repo in my ~/common-lisp directory. So that solves the issue of my last comment. However, some build error remains even after pulling the latest version of the repo. So as you requested I will open a new issue for that. |
The INSTALL file is the step after checking out.
The instructions for checking out the repository are in
documents/README.org, which mentions the ~/common-lisp folder.
Does that make sense?
|
Well it sounds sensible but maybe it makes more sense when I get more
experienced. For now I am happy if "full" build instructions, or references
to these instructions are in the INSTALL file. Also, I've build next
successfully before, and it would be great to not have to read the README
again if I want to rebuild it again. In my opinion it would be worth it to
remind in the INSTALL file about updating to latest versions of quicklisp
and cl-webkit (and next repo itself), and additionally that for successfull
completion of the INSTALL file instructions it should be located in the
`~/common-lisp/next` directory, in that way it is easier for ordinary
users, i.e. non-developers, like me to contribute useful feedback.
…On Sat, 23 May 2020 at 14:11, Pierre Neidhardt ***@***.***> wrote:
The INSTALL file is the step after checking out.
The instructions for checking out the repository are in
documents/README.org, which mentions the ~/common-lisp folder.
Does that make sense?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#447 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEMTOX52JWA5HOMK7DP4N2TRS64QXANCNFSM4I5VTBTA>
.
|
I've added a warning about outdated quickdist / libraries in
0d3335d.
Note that Next can be cloned outside of ~/common-lisp. This
recommendation is mostly for people who want to load Next from a Common
Lisp REPL (e.g. SLIME / SLY).
The INSTALL instructions are meant to be quite stable. The reason it
didn't work out for you previously is because you were using an outdated
Next checkout that didn't automatically update the Quickdist /
cl-webkit. We do this now.
Let me know if there is anything else.
|
@Ambrevar I've successfully installed latest next with guix. However the (in-package :next-user)
(defvar *my-keymap* (make-keymap "my-map"))
(define-key *my-keymap*
"C-m" 'switch-buffer)
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-scheme :initform (keymap:make-scheme
scheme:emacs *my-keymap*
scheme:vi-normal *my-keymap*))))
(define-configuration buffer
((default-modes (append '(my-mode) %slot-default)))) And I can't do |
Are you using CUA, Emacs or VI binding?
The default scheme is CUA. Bring up the command menu with C-space.
This should be explained (with dynamic bindings) on the start page.
In your example you haven't set the keymap for scheme:cua which is why
you may not be able to call it from the CUA scheme.
|
this works for me (in-package :next-user)
(defvar *my-keymap* (make-keymap "my-map"))
(define-key *my-keymap*
"S-m" 'switch-buffer)
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-scheme :initform (keymap:make-scheme
scheme:cua *my-keymap*
scheme:emacs *my-keymap*
scheme:vi-normal *my-keymap*))))
(define-configuration buffer
((default-modes (append '(my-mode emacs-mode) %slot-default))))
|
(in-package :next-user)
You don't need this line as it is the default.
(defvar *my-keymap* (make-keymap "my-map"))
(define-key *my-keymap*
"S-m" 'switch-buffer)
(define-mode my-mode ()
"Dummy mode for the custom key bindings in `*my-keymap*'."
((keymap-scheme :initform (keymap:make-scheme
scheme:cua *my-keymap*
scheme:emacs *my-keymap*
scheme:vi-normal *my-keymap*))))
(define-configuration buffer
((default-modes (append '(my-mode emacs-mode) %slot-default))))
This is what is presented in the tutorial (minus the emacs-mode
default).
Would you like to suggest an improvement to the documentation?
|
Sure! |
Which one?
|
I want to set the following keybindings:
(define-key :keymap my-keymap "r" #'history-forwards)
(define-key :keymap my-keymap "g" #'history-backwards)
(define-key :keymap my-keymap "u" #'set-url-current-buffer)
(define-key :keymap my-keymap "c" #'scroll-up)
(define-key :keymap my-keymap "t" #'scroll-down)
(define-key :keymap my-keymap "d" #'scroll-page-up)
(define-key :keymap my-keymap "s" #'scroll-page-down)
It's inspired by https://github.com/xahlee/xah-fly-keys Dvorak layout and what I currently use for my browsers. (vimium extension for firefox/chromium, vimb...)
The text was updated successfully, but these errors were encountered: