Emacs key setup/mapping

I am struggling a bit with proper key setup for Emacs on Haiku.

describe-key for backspace says “DEL (translated from <backspace>)” and describe-key for delete says “DEL (translated from <delete>)”, so they both do the same thing (i.e. backward-delete-char-untabify), but what I want is to run “delete-forward-char” for the delete key.

On Linux it says "<deletechar> (translated from <delete>)" for the delete key and I get the expected behaviour. Anyone know how I can get a similar setup on Haiku?

Another issue appears to be that Ctrl-/ doesn’t do anything on Haiku Emacs (it doesn’t even seem to get to the process as there is no reaction when pressing Ctrl-/ in a describe-key). Any ideas?

(define-key local-function-key-map (kbd "<delete>") [deletechar])

seems to help with the delete key mapping.

I think I asked @hgsfghs about this once on IRC because I was having trouble with Ctrl-;

Maybe he’ll be able to offer some guidance here.

I can’t see what it was translated from, because I guess it was not pasted correctly into the forum software. Do they both translate from `<backspace>’ on Haiku?

Oops, didn’t notice, edited to post. One was from <delete>, the other from <backspace>.

Right, that seems correct. What happens if you turn on `normal-erase-is-backspace-mode’?

Nevermind, I see what needs to be done. Does this fix the issue:

diff --git a/lisp/simple.el b/lisp/simple.el
index 4551b749d56..a38426060e0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10317,7 +10317,7 @@ normal-erase-is-backspace-setup-frame
        (if (if (eq normal-erase-is-backspace 'maybe)
                (and (not noninteractive)
                     (or (memq system-type '(ms-dos windows-nt))
-			(memq window-system '(w32 ns pgtk))
+			(memq window-system '(w32 ns pgtk haiku))
                         (and (eq window-system 'x)
                              (fboundp 'x-backspace-delete-keys-p)
                              (x-backspace-delete-keys-p))

Is there an easy way to change those files on a running system without having to rebuild emacs?

Anyway, played around a bit and I think in addition to the change in simple.el we also need to change display-symbol-keys-p in frame.el so it returns true for haiku.

Yes, just apply the patch to simple.el and run eval-defun. Then, create a new frame.

Please let me know once you try both, thanks.

Well, I put it into .emacs and it seems to work after doing normal-erase-is-backspace-mode twice which I guess means that it does work (just doesn’t automatically take effect when starting emacs, as it’s only in .emacs)

Did you put the patch into .emacs? Could you please show that code?

It’s getting awfully close to Emacs 29 being released, so right now we are rather reluctant to make any (even tiny) changes to Emacs 29 branch. But I’d like to see this issue fixed there.

(defun display-symbol-keys-p (&optional display)
  "Return non-nil if DISPLAY supports symbol names as keys.
This means that, for example, DISPLAY can differentiate between
the keybinding RET and [return]."
  (let ((frame-type (framep-on-display display)))
    (or (memq frame-type '(x w32 ns pc pgtk haiku))
        ;; MS-DOS and MS-Windows terminals have built-in support for
        ;; function (symbol) keys
        (memq system-type '(ms-dos windows-nt)))))

(defun normal-erase-is-backspace-setup-frame (&optional frame)
  "Set up `normal-erase-is-backspace-mode' on FRAME, if necessary."
  (unless frame (setq frame (selected-frame)))
  (with-selected-frame frame
    (unless (terminal-parameter nil 'normal-erase-is-backspace)
      (normal-erase-is-backspace-mode
       (if (if (eq normal-erase-is-backspace 'maybe)
               (and (not noninteractive)
                    (or (memq system-type '(ms-dos windows-nt))
			(memq window-system '(w32 ns pgtk haiku))
                        (and (eq window-system 'x)
                             (fboundp 'x-backspace-delete-keys-p)
                             (x-backspace-delete-keys-p))
                        ;; If the terminal Emacs is running on has erase char
                        ;; set to ^H, use the Backspace key for deleting
                        ;; backward, and the Delete key for deleting forward.
                        (and (null window-system)
                             (eq tty-erase-char ?\^H))))
             normal-erase-is-backspace)
           1 0)))))
2 Likes

The delete key seems to be functioning properly after rebuilding Emacs with both of those changes(display-symbol-keys-p and normal-erase-is-backspace-setup-frame)

Still need to figure out why several of the control keys don’t seem to be generating any input(C-; C-/ C-, C-.) :thinking:

2 Likes

The control keys things seems to be something in the input server.

I’ll ask to see if the other two are ok for Emacs 29. Thanks.

I’ve installed both changes in Emacs 29.

2 Likes