Skip to content

Instantly share code, notes, and snippets.

@573
Last active August 27, 2024 11:06
Show Gist options
  • Save 573/9d8b18d01a115d11589108d758bb6b97 to your computer and use it in GitHub Desktop.
Save 573/9d8b18d01a115d11589108d758bb6b97 to your computer and use it in GitHub Desktop.
edit text on web pages with emacs
;; For Windows emacs this file belongs to $env:APPDATA
;; M-: buffer-file-name.
;; (GNU Emacs 29.4 (build 2, x86_64-w64-mingw32) of 2024-07-05)
;; If you don't have MELPA in your package archives:
(require 'package)
(add-to-list
'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) ; Org-mode's repository
(package-initialize)
(package-refresh-contents)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ispell-alternate-dictionary "C:\\Users\\dkahlenberg\\.aspell.LANG.pws")
'(package-selected-packages
'(websocket emacs-everywhere jira-markup-mode atomic-chrome org-dropbox org-plus-contrib ## weblogger)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; next line is an exception, melpa did not find atomic-chrome, so
;; I used the instructions as listed in this fork
;; https://github.com/KarimAziev/atomic-chrome?#manual-installation
(add-to-list 'load-path "~/.emacs.d/atomic-chrome/")
(require 'atomic-chrome)
(atomic-chrome-start-server)
;;(setq atomic-chrome-buffer-open-style 'frame)
;; (setq atomic-chrome-server-ghost-text-port 4002)
;;(setq atomic-chrome-extension-type-list '(atomic-chrome))
;;(setq atomic-chrome-default-major-mode 'jira-markup-mode)
(defun my/jira-markup-insert-code-block ()
"Insert markup for a block of code.
If Transient Mark mode is on and a region is active, it is made a
code block."
(interactive)
(insert "{code}\n" "\n{code}\n")
(backward-char 8))
(defun my/jira-markup-insert-table-header ()
"Insert markup for a table header."
(interactive)
(insert "||" "||")
(backward-char 2))
(defun my/jira-markup-insert-pipechar ()
"Insert a |."
(interactive)
(insert "|")
(backward-char 0))
(defun my/jira-markup-insert-table-cell ()
"Insert markup for a table cell."
(interactive)
(insert "|" "|")
(backward-char 1))
(defun my/jira-markup-insert-url ()
"Insert markup for an url link."
(interactive)
(insert "[" "|]")
(backward-char 2))
(defun my/jira-markup-insert-ticket-link ()
"Insert markup for a table cell."
(interactive)
(insert "[MGM-" "]")
(backward-char 1))
(defun my/jira-markup-insert-bareurl ()
"Insert markup for an url link without alt."
(interactive)
(insert "[" "]")
(backward-char 1))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "C-c s") 'my/jira-markup-insert-code-block))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "||") 'my/jira-markup-insert-table-header))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "| SPC") 'my/jira-markup-insert-pipechar))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "|\\") 'my/jira-markup-insert-table-cell))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "[ SPC") 'my/jira-markup-insert-url))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "[ M\\") 'my/jira-markup-insert-ticket-link))
(eval-after-load 'atomic-chrome-edit-mode
(define-key atomic-chrome-edit-mode-map (kbd "[]") 'my/jira-markup-insert-bareurl))

When package-install doesn't find a package do (https://stackoverflow.com/a/24836870):

M-x package-list-packages

C-s <packagename>
No need to guess. If you want to find out the current active keymap in a given situation, like in the gnus group buffer, use this command:

    M-: (mapcar (lambda(x)(car(rassq x minor-mode-map-alist)))(current-minor-mode-maps))

Thanks to David Kastrup for giving it to me. --memnon

you might need to wait for the correct mode to be loaded before seting the key

    (eval-after-load 'text-mode
                     '(define-key text-mode-map (kbd "'") 'maybe-open-apostrophe))

~/.emacs:

;; If you don't have MELPA in your package archives:
(require 'package)
(add-to-list
  'package-archives
  '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) ; Org-mode's repository
(package-initialize)
(package-refresh-contents)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages
   '(jira-markup-mode atomic-chrome org-dropbox org-plus-contrib ## weblogger)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(require 'atomic-chrome)
(atomic-chrome-start-server)
(setq atomic-chrome-buffer-open-style 'frame)
(setq atomic-chrome-extension-type-list '(atomic-chrome))
(setq atomic-chrome-default-major-mode 'jira-markup-mode)
(defun my/jira-markup-insert-code-block ()
  "Insert markup for a block of code.
If Transient Mark mode is on and a region is active, it is made a
code block."
  (interactive)
  (insert "{code}\n" "\n{code}\n")
  (backward-char 8))

(defun my/jira-markup-insert-table-header ()
  "Insert markup for a table header."
  (interactive)
  (insert "||" "||")
  (backward-char 2))



;;(defun my/add-jira-code-binding ()
;;  "Keymap for Jira-Markup major mode."
;;   (local-set-key (kbd "C-c C-s C") #'my/jira-markup-insert-code-block))

;; (add-hook 'jira-markup-mode-hook #'my/add-jira-code-binding)
(eval-after-load 'atomic-chrome-edit-mode
  (define-key atomic-chrome-edit-mode-map (kbd "C-c s") 'my/jira-markup-insert-code-block))
(eval-after-load 'atomic-chrome-edit-mode
  (define-key atomic-chrome-edit-mode-map (kbd "||") 'my/jira-markup-insert-table-header)
  )

import attached xml in Aufgabenplanung ("C:\WINDOWS\system32\mmc.exe" "C:\WINDOWS\system32\taskschd.msc" /s), but before replace [[ ... ]], to have emacs daemon running.

but take care of alpha22jp/atomic-chrome#80

shortcut to open files with:

"C:\Program Files\Emacs\emacs-29.4\bin\emacsclientw.exe" -create-frame -n -t -a ""
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-02-27T15:46:44.0574695</Date>
<Author>[[ replace your user ]]</Author>
<Description>see https://gist.github.com/573/9d8b18d01a115d11589108d758bb6b97</Description>
<URI>\emacs damon as service</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
<UserId>[[ replace your user ]]</UserId>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-[[ replace Administrator, see "S-1-5-Domäne-500 Administrator" here https://learn.microsoft.com/de-de/windows-server/identity/ad-ds/manage/understand-security-identifiers ]]</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT5M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Program Files\Emacs\emacs-29.4\bin\runemacs.exe"</Command>
<Arguments>--daemon</Arguments>
</Exec>
</Actions>
</Task>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment