all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: input methods for mathematical glyphs
Date: Wed, 08 Dec 2021 19:43:32 +0100	[thread overview]
Message-ID: <87a6hbx7hn.fsf@zoho.eu> (raw)
In-Reply-To: 87ilvzx7z6.fsf@zoho.eu

> My second thought is a virtual keyboard and a shortcut to
> enable it (say `C-h g' for "CHange to Greek" :)), that
> keyboard will then take over the normal keyboard so if you
> press 'd' a downcase delta will be inserted (and so on), and
> either it will automatically go back to the normal keyboard
> at that point after insertion, _or_ you'd have to do `C-h g'
> again for it to return ...

If you like this idea, it can be done easily (I think) based
on this:

;;; caps-back.el --- one-keystroke word pre-capitalizer -*- lexical-binding: t -*-
;;;
;;; Commentary:
;;;
;;; Author: Emanuel Berg (incal) <moasenwood@zoho.eu>
;;; Created: 2021-05-23
;;; Keywords: caps lock key
;;; License: GPL3+
;;; URL: https://dataswamp.org/~incal/emacs-init/caps-back.el
;;; Version: 2.0.0
;;;
;;; This minor mode capitalizes the entire next word that is
;;; typed, at the same time as it is typed, then quietly
;;; disables itself at the word boundary.
;;;
;;; For this to work efficiently, a short and close keystroke,
;;; optimally a single key, should be assigned to invoke the
;;; minor mode, which happens with the
;;; `toggle-caps-mode' function.
;;;
;;; Setup a shortcut like this:
;;;
;;;   (global-set-key KEY #'toggle-caps-mode)
;;;
;;; Then, hit \\[toggle-caps-mode] and type one and only one
;;; WORD in caps.
;;;
;;; Code:

(defun char-alphanum-or-dash (c)
  "True if C is a character, a number, or a dash."
  (or (eq c ?-)
      (member c '(?å ?Å ?ä ?Ä ?ö ?Ö))
      (and (>= c ?1) (<= c ?9))
      (and (>= c ?A) (<= c ?Z))
      (and (>= c ?a) (<= c ?z)) ))

(defun caps-mode-self-insert-command (n)
  "Insert the `last-command-event' char N times.
Uppercase unless something else than an alphanum or a dash."
  (interactive "p")
  (let*((the-char last-command-event)
        (alphanum-or-dash (char-alphanum-or-dash the-char)))
    (if alphanum-or-dash
        (insert-char (upcase the-char) n)
      (caps-mode 0)
      (insert-char the-char n) )))

(defvar caps-mode-map
  (let ((map (make-keymap)))
    (substitute-key-definition #'self-insert-command
                               #'caps-mode-self-insert-command
                               map global-map)
    map) )

(define-minor-mode caps-mode
  "Caps on you."
  :init-value nil
  :lighter " Caps")

(defun toggle-caps-mode ()
  "Toggle Caps mode."
  (interactive)
  (caps-mode 'toggle) )

(provide 'caps-back)
;;; caps-back.el ends here

-- 
underground experts united
https://dataswamp.org/~incal




  parent reply	other threads:[~2021-12-08 18:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 16:40 input methods for mathematical glyphs Leo Butler
2021-12-08 17:18 ` Eli Zaretskii
2021-12-08 19:52   ` Marcin Borkowski
2021-12-08 23:15     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-09  5:20       ` Marcin Borkowski
2021-12-09 10:03         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-10  5:49           ` Marcin Borkowski
2021-12-10  5:58             ` Po Lu
2021-12-10 13:18               ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-12-10 17:08                 ` H. Dieter Wilhelm
2021-12-10 17:28                   ` Stefan Monnier
2021-12-10 17:34                     ` H. Dieter Wilhelm
2021-12-08 20:07   ` Leo Butler
2021-12-08 20:15     ` André A. Gomes
2021-12-09 14:24       ` Leo Butler
2021-12-08 20:15     ` Eli Zaretskii
2021-12-08 20:42   ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-12-09 14:26     ` Leo Butler
2021-12-08 18:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-08 18:38   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-08 18:43   ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2021-12-09  3:05     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-08 19:41 ` André A. Gomes
2021-12-08 23:11   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-09 14:08     ` André A. Gomes
2021-12-09 14:24       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-09 22:06         ` André A. Gomes
2021-12-08 20:35 ` Eduardo Ochs
2021-12-08 21:59   ` H. Dieter Wilhelm
2021-12-09 14:55   ` Leo Butler
2021-12-09 16:06     ` Eduardo Ochs
2021-12-09 16:22       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-12-09 17:39       ` Leo Butler
2021-12-09 18:21         ` Eduardo Ochs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6hbx7hn.fsf@zoho.eu \
    --to=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.