texts: Cannot run melpa package refresh due to gpg errors

texts:
Root task: trying to install R mode for emacs (ESS following - https://stackoverflow.com/questions/1422987/emacs-mode-for-r)
OS: Ubuntu 18.04
Problem: When I run M-x package-refresh-contents RET
I get the following error:
Failed to verify signature archive-contents.sig:
No public key for 066DAFCB81E42C40 created at 2020-09-08T10:05:02+0100 using RSA
Command output:
gpg: WARNING: unsafe permissions on homedir '/home/xxx/.emacs.d/elpa/gnupg'
gpg: Signature made Tue 08 Sep 2020 10:05:02 BST
gpg:                using RSA key C433554766D3DDC64221BFAA066DAFCB81E42C40
gpg: Can't check signature: No public key

I tried following the accepted answer at: How to proceed on package.el signature check failure
Updating the public keys using M-x package-install RET gnu-elpa-keyring-update RET gives [No match].
If I try to update the keys manually using gpg:
gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40

gives
gpg: WARNING: unsafe permissions on homedir '/home/xxx/.emacs.d/elpa/gnupg'
gpg: keyserver receive failed: General error

Sure enough if I go to keyserver.ubuntu.com and search for the fingerprint I find nothing. Furthermore, if I try to extend the expiration date of the old key (another workaround suggested):
gpg  --quick-set-expire 474F05837FBDEF9B 1y

gives
gpg: "474F05837FBDEF9B" is not a fingerprint

Can anyone explain why this is failing? I'm not massively familiar with gpg.
Update
Following advice in the comments I managed to fix the permissions on ~/.emacs.d/elpa/gnupg so the warning is gone, however the error persists. Running M-x package-refresh-contents RET now results in:
Failed to verify signature archive-contents.sig:
No public key for 066DAFCB81E42C40 created at 2020-09-09T10:05:02+0100 using RSA
Command output:
gpg: Signature made Wed 09 Sep 2020 10:05:02 BST
gpg:                using RSA key C433554766D3DDC64221BFAA066DAFCB81E42C40
gpg: Can't check signature: No public key

Similarly, running:
gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40
just gives:
gpg: keyserver receive failed: General error


texts: Read-only text stops working after a while

texts:
This is a very strange issue and its cause is hard to determine. I often leave Emacs open for days, or even weeks at a time. My current emacs-uptime is 9 and a half days. That's pretty normal and sometimes it can be twice as long or longer.

However, sometimes when I run Emacs for this long and I happen to push Emacs particularly hard (running lots of processes, opening big files, using strange settings, etc.) something weird happens after some days. Emacs randomly blinks all of a sudden, like it's doing redisplay or something. This lasts for about a second or less. Thereafter, read-only text is not read-only anymore. I mean that any read-only text anywhere in Emacs is no longer read-only. REPL prompts, info buffers, help buffers, eshell prompts, buffers set to view-mode, any buffer in read-only-mode, anything else you can think of.

Basically, all read-only text becomes writable. At all, anywhere. I can accidentally clobber documentation by pressing a key that would normally do nothing or I can accidentally delete a REPL prompt which can screw up all kinds of things when developing. The only way around this issue (that I know of) is to restart Emacs. This is not always a viable solution. As you can see, this is a very annoying and often serious problem. But I cannot find anyone else online who has had this same issue.

So how can I determine what is causing this issue? And more importantly, how can I fix it?

Here is my emacs-version:

GNU Emacs 26.1 (build 5, x86_64-apple-darwin17.6.0, Carbon Version 158 AppKit 1561.4)
 of 2018-07-17

I.e., I'm on the Emacs Mac Port (by Yamamoto Mitsuharu) version 26.1. Also, my OS is macOS 10.13.6. I am happy to give more information about my setup as it becomes necessary.


texts: Why does the member function return a list's tail rather than t?

texts:
Why does Elisp (member '3 '(1 2 3 4 5 6)) return (3 4 5 6) instead of t (true) or 3, or (3)?

I see the utility of a function to return the remainder/tail of an ordered list starting from, and including the delimiter element.

But why have it as a "side-effect" to the function for checking existence in a set?

Ever since I first read about member, I wondered about this, but quietly accepted. Now recently this topic came up, and I have a few ideas, like this being about keeping the number of C-primitives low by adding semantics to the non-false return values? Or is it a "hold-over" from the math paper(s) all of Lisp derived from? Or something else? Is there a (definitive) source out there?


texts:
I been reading a blog post from Chris Wanstrath from 2010 where he write about coffee-mode. He proposed there this functions hook:

(defun coffee-custom ()
  "coffee-mode-hook"

  ;; Emacs key binding
  (define-key coffee-mode-map [(meta r)] 'coffee-compile-buffer))

(add-hook 'coffee-mode-hook (lambda () (coffee-custom)))

In coffee-mode.el you can see similar hook call
"... Add `(lambda () (coffee-cos-mode t))' to `coffee-mode-hook' to turn
it on by default."

I don't understand the use of lambda calling another function in order to execute it. Why not simply:
(add-hook 'coffee-mode-hook #'my:coffee-custom)

Resources: http://ozmm.org/posts/coffee_mode.html


texts:
Consider the following form:
(pcase '(:def "k" #'foo :wk "ho")
  (`(:def
     ,(and (or (pred stringp) (pred vectorp)) key)
     ,(and (pred xl-sharp-quoted-symbol-p) def)
     :wk
     ,(and (pred stringp) desc))
   (format "%s | %s | %s" key def desc)))
;; =>
"k | #'foo | ho"

Suppose that I want the keywords :def and :wk to be optional. In other words I want the pcase form to successfully parse the following lists:
'("k" #'foo "bar")
'("k" #'foo :wk "bar")
'(:def "k" #'foo "bar")

Of course I realize it is possible to copy over the clause in my first example in all possible combinations omitting either :def, :wk or both. However, that's tedious and duplicates much code.
I wish I could do something like this:
(pcase '(:def "k" #'foo :wk "ho")
  (`(,(optional :def)
     ,(and (or (pred stringp) (pred vectorp)) key)
     ,(and (pred xl-sharp-quoted-symbol-p) def)
     ,(optional :wk)
     ,(and (pred stringp) desc))
   (format "%s | %s | %s" key def desc)))

Is there a way to do this concisely with pcase? If so, how?


texts: Temporarily set the `default-directory` for `start-process`

texts:
Is it possible to set the default-directory temporarily (e.g., let-bound) when using start-process?  If so, how please.

(let ((default-directory "/Users/HOME/Desktop/tmp"))
  (start-process "touch-file" nil "touch" "test.txt"))

start-process ignores a let-bound default-directory.


texts: How can I get Emacs to launch new frame when a file is dropped onto the Dock icon?

texts:
I have Emacs installed with brew install emacs-mac --HEAD --with-cocoa --with-gnutls --with-librsvg --with-imagemagick. I have the final .app binary in the OS X Dock.

If I drag a file onto the Dock icon, the default behavior opens it in the last-activated frame, even if it is on a different desktop. I'd like files to open in a new frame in the current desktop when drag-and-dropped onto the icon. Is this behavior possible? Yes, because this is emacs. Can anyone suggest a place to begin implementing this?


texts: Display lambda expression as let-bound symbol

texts:
Q:  How can I display this let-bound lambda expression as a symbol -- i.e., display it as my-func instead of (lambda (arg1 ...))?

I'd like the best of both worlds -- i.e., be able to use funcall in one area of the code, yet extract a pretty name my-func from my-list elsewhere in the code.

  (let* (
    (my-func
      (lambda (arg1 arg2 arg3)
        (message "arg1: %s | arg2: %s | arg3: %s" arg1 arg2 arg3)))
    (my-list (list my-func '("foo" "bar" "baz"))))
  (apply 'funcall (car my-list) (car (cdr my-list)))
  (message "I want my-func to appear as \"my-func\":  %s" (car my-list)))


texts: How to keep Ivy from quitting when I press backspace in the minibuffer?

texts:
It's pretty annoying when I hold down Backspace one character too long in the minibuffer, causing Ivy to quit and then accidentally deleting some characters in the main buffer I'm working in.

How do I change this behaviour?


texts:
As I write progressively more ambitious macros I find my (declare (debug specs)) more involved. There're times where I really wish I could step debug the spec matching itself, or at least perform the match on some form given a spec. Looks like Edebug has all the required parts in place, but it is so stateful that I keep running into errors where some flag or index is set to the wrong thing, etc. I just can't figure out all the wrapping I need to do to match some form against the speclist I supply. This is as far as I've gotten:

(defun match-debug-spec (form specs)
  (with-temp-buffer
    (insert (format "%S" form))
    (goto-char (point-min))
    (let* (edebug-offsets
           (cursor (edebug-new-cursor
                    (list (edebug-read-storing-offsets (current-buffer)))
                    (list edebug-offsets))))
      (edebug-match cursor specs))))

(match-debug-spec
 '(funcall (lambda (a b &rest args) (list* a b args)) 1 2 3 4)
 '(&rest form))

This is where I get (void-variable edebug-offset-index) error. I tinkered a lot, but I run into something every time. Doesn't help that the implementation isn't exactly documented. I have to guess at what cursors are and all the magic it performs while instrumenting code. Can anyone give pointers?

Someone spec'ed the entire CL package and I refuse to believe they managed to convince the spec matcher just by trial and error. How do I do it systematically?


texts: What is causing Emacs remote shell to be slow on completion?

texts:
So basically I am doing the following:

Opening a dired buffer with tramp on a remote.
Opening a shell on the remote (M-x shell)

Then if I try for example to type any command such as ls -la the prompt will display l and then take something like 10 seconds to display the remaining input.
If I C-g when the prompt is stuck at l then the hang time will disappear, and the remaining input will be directly displayed.
I believe this could be a completion problem, for some reason from my config emacs would be searching for stuff on the remote. As another thread mentioned I tried disabling (global-projectile-mode). I also have company installed.
The hard thing for debugging is that no output is displayed in messages. Any ideas on what may be causing this hang time?


texts: org-alert and alert not working on MacOS

texts:
There is an open issue on working with alert on MacOS https://github.com/jwiegley/alert/issues/47.
If you want to work with org-alert or org-wild-notifier and you have troubles cause you need this dependency you can use this workaround.
https://github.com/jwiegley/alert/issues/47#issuecomment-812385081
Similarly you can modify the org-wild-notifier--notify function.


texts: How to obtain a list of all functions exclusively provided by a certain major mode

texts:
This question in inspired by https://stackoverflow.com/q/605785/.
By M-x describe-function <TAB> I can get a list of all
interactive or nonintractive functions available in the current state
of emacs.
If an specific mode is activated (e.g. latex-mode) we get a longer
list, as the functions available in latex-mode are also listed.

My question is how to obtain a list of all functions exclusively available in an
specific mode (e.g. latex-mode)? In other words excluding all other
functions not provided by that mode. Like in the above link providing a short description of the functions would also be handy.


texts: Is there a clean way to splice some args to an existing Lisp macro?

texts:
I have the following non-working elisp code:

(use-package eglot
         ;; For debug/testing, load local copy of eglot if it exists
         ,@(if (file-directory-p (concat user-emacs-directory "/eglot"))
               '(:load-path "eglot/")
             '(:quelpa ((eglot :fetcher github :repo "joaotavora/eglot"))))
         :commands eglot
         :hook ((vue-mode . eglot-ensure)
                (typescript-mode . eglot-ensure)
                (javascript-mode . eglot-ensure))
         :config
         (add-to-list 'company-backends  'company-capf))

You can see what I'm after -- if ~/.emacs.d/eglot exists, use the package from my local dir. Otherwise use quelpa to fetch it from its repo. I'm doing this because I'm working on some fixes. The idea is to use ,@ to interpolate items into the arg list.

But of course you can't use ,@ outside of a backquoted list. So I know I could pull all the args out and use (apply 'use-package eglot-args) but I'm wondering if there's a clever Elisp syntax to interpolate a list into an arg list dynamically like this.


texts: Leave evil's insert state with Control + c

texts: I would like to be able to leave the insert state (I think that's what it's called in emacs?) using the Ctrl+c combination I know from vim. I'm using doom-emacs in case that's important, and I'm completely new to emacs.


texts: Org-mode: force subheading to end and continue in parent heading

texts:
Say I'm writing a text:

* Animals

There are many of them in the wild.

** Examples of animals :noexport:
- Dogs
- Fish
- Triceratops

# I'd like the subheading to end here!! Following sentence should belong to outer scope.

Animals are not the same as plants.

* Plants

There are also many of them in the wild.

I'd like my subheading Examples of animals in the example above, to end after - Triceratops, and all further text to continue on the parent heading Animals. Currently, if I cycle visibility and hide Examples of animals, then all text below it will be hidden up entil the next heading.

How can I force to prematurely end a headline?!

If this functionality is not implemented in org-mode, how can I insert structured text in the middle of a heading and selectively hide (org-cycle) it?


texts: Any idea how turn quotes into double quotes?

texts:
One of the things that I love in Vim, was the faster way of insert double quotes (saves me hitting the shift key"

 inoremap '' ""<Left>

So when I press the single quote, and type further, I get the quote and the text, which I close with the closing quote, like 'foo bar'
But when I double tap the quote, I get double quotes instead, then I get "foo bar". Evil doesn't support if the next character after the single quote is not included in the configuration. I tried various ways to figure out how I could get this feature.

Any suggestions how I could configure this feature in Elisp? (I'm using Evil mode by the way, if that helps).


texts: Magit: Is it possible to show 2 states of file? Before change and after change

texts:
Windows 10, Emacs 25.1. , Magit

I have xml file. And I remove 8 lines and add 2 lines.

Here result in SmartGit:

As you can see it's very simple to understand the state of file: before change and after change. It's very convenient.

Now how this file look in Magit:

As you can see all changes are in ONE buffer. It's not very convenient.

The question is: Is it possible to show change in 2 buffers? One buffer to show content of file before change and another buffer to show file after change. Like in SmartGit.

Thanks


texts: Customize Org agenda entry based on properties in TODO items

texts:
I'm trying to show certain icons to the left of TODO items in the agenda based on the presence of a property.

For example, if TODO item A has the "important" property, show an exclamation mark:

!  TODO A
   TODO B

It looks like this can be customized with org-agenda-prefix-format using the %(expression) syntax, but I encounter bizarre issues when using the following syntax:

(defun show-exclamation-if-important()
  (save-window-excursion
    (org-agenda-goto)
    (if (org-entry-properties (point) "important")
        "!"
      " ")))

This combined with using %(show-exclamation-if-important) returns user-error: Command not allowed in this line. It seems to be an issue with the excursion of some sorts?

Simply put, how can I get a return value of the properties of a TODO item while on the corresponding agenda entry?


texts: Make org-mode display images from the Internet in your org file

texts:
I have a list of tasks I need to complete for a project I'm working on in a org file. The thing is that I would like to display the Wercker's status images of my project on that file to know how the unit tests are doing without visiting the Wercker site or the front page of my project's repo.

How can I achieve this?


texts: Problems with upgrading to org-mode 9 and org repository

texts:
I have Emacs 25.1 (9.0) on macOS Sierra from Homebrew and M-x org-version shows version 8.2.10. On org-mode official website, I've seen that the latest version is 9.0. It's not that I'd use any of the newest features, but it bothers me that Emacs won't update. I have the following lines in my init.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)

Running M-x package-list-packages seems to at least connect to repositories and fetch some metadata (there is some activity on the mode-line and apparently no error is returned). Pressing U-x says it has no packages to update and the curious thing is that while I see packages from melpa and gnu, there's nothing from org repository (see screenshot). Why can't I update to org-mode 9.0 and why there's no package from org repo in my list?

On Windows 10 (Emacs 25.1.1), with the exact same init.el as on macOS, I have org-mode version 9.0.6.


texts: Setting variable for org-mode html export?

texts:
I am trying to set org-html-link-org-files-as-html to nil for a single org-file (but have the value equal t for all other org files). This is a variable defined in ox-html.

(defcustom org-html-link-org-files-as-html t
  "Non-nil means make file links to `file.org' point to `file.html'.
When `org-mode' is exporting an `org-mode' file to HTML, links to
non-html files are directly put into a href tag in HTML.
However, links to other Org-mode files (recognized by the
extension `.org.) should become links to the corresponding html
file, assuming that the linked `org-mode' file will also be
converted to HTML.
When nil, the links still point to the plain `.org' file."
  :group 'org-export-html
:type 'boolean)

I have tried setting

#+OPTIONS: org-html-link-org-files-as-html:nil

and setting

# -*- org-html-link-org-files-as-html:nil; -*-

at the top of the file. Neither work - only works when I set in emacs-lisp

(setq org-html-link-org-files-as-html nil)

but then this applies to all org files. Can I set it for a single org-file?


texts: org-mode agenda in the background asynchronously

texts:
Is a way to process the org-agenda asynchronously in the background as it takes a long time?

I'm using the latest emacs (master branch as of 1week ago and org version 9.0.5).


texts: When switching buffers, prevent emacs from automatically switching frame

texts:
When I switch buffers, emacs will switch to an existing frame if the buffer is already opened there.

I found how to prevent that when switching with ido using :

(setq ido-default-buffer-method 'selected-window)

But it's not enough : for exemple if there's a lisp error emacs will automatically switch to the buffer *Backtrace*, and will switch frames if it's already open.

Is there a way to prevent completely emacs from switching to an existent frame?


texts: How to prevent `TAB` from adding a newline for each new address (To/Cc), in Gnus + BBDB?

texts:
When I'm adding a comma and a new address at To or Cc or Bcc in Gnus, there is a new line added when completing the address. I end up with:

My Address <address@example.com>,
Another Address <another@example.com>,
Yet Another <yet@example.com>

instead of

My Address <address@example.com>, Another Address <another@example.com>, Yet Another <yet@example.com>

Each TAB I use for completion results in the addition of a newline. And I can't sent the message, all addresses must be one one line.

How can I fix this to not add a newline when using TAB for address completion?

I'm using Emacs 25.2.2, Gnus 5.13, BBDB 3.2.


texts: Is it possible to remove '\emsp' from clock report but preserve indentation?

texts:
Is it possible to replace '\emsp' with just plain spaces?

I.e,
In Clock reports, there are a lot of these '\emsp's. (See example below.)

I'm able to get rid of them by setting ':indent nil'. But this removes all indent altogether, which is undersirable. I can also get rid of them if I export things. But in the Agenda view I don't export reports and the \emsp's are just a visual distraction.

So far I was able to remove 'TODO' keywords via formatter as described here. But the formatter doesn't seem to see the '\emsp' and can't remove them. It kinda seems like they are added after.

|-----------+-------------------------------------------------------------------+---------+------|
| dev.org   | *File time*                                                       | *9:54*  |      |
|           | Dev                                                               | 9:54    |      |
|           | \emsp Configure VMs for testing [[elisp:(my/goto-parent)][parent]]                            |         | 5:03 |
|           | \emsp test if DND works in outline view in Mars (4.5) Build id: I20150217-0800 has outline view fixed (RHBZ#1012336). |         | 0:16 |
|           | \emsp GtkMenuItem directly instead of GtkImageMenuItem            |         | 1:28 |
|           | \emsp Bug 459487 - [GTK] Replace deprecated gtk_arrow_* with gtk_image |         | 1:31 |
|           | \emsp General                                                     |         | 1:36 |


texts: How to jump to backward found word when switched into reverse incremental search?

texts:
When I do I-search: or I-search-backward , it starts right away from the first word it find.

Original behavior:

word1                                           |[cursor]word1 ; cursor moves here
wor[cursor]d2 ;<= I press `ctrl+r` word [enter] |word2
word3                                           |word3

For example, when I am in I-search, I want to start doing backward search and press ctrl+r but in the first press it remains in the current found word (cursor move into its beginning) and on the second press to ctrl+r, `emacs jumps to the found word on backward.

Example:

word1                                           |word1
wor[cursor]d2 ;<= I press `ctrl+s` word [enter] |word2
word3                                           |word3[cursor]; cursor moves here

then

word1                                           |word1
word2                                           |word2
word3[cursor] ;<= I press `ctrl+r` word [enter] |[cursor]word3 ; cursor moves here

at this stage I want cursor to move beginning of word2 like it should do on its original behavior.

=> I was wondering when the switch from I-search: to I-search-backward or visa versa, can the action take place on the first click instead of two?


texts:
When I export my documents to pdf (as pdf file and open C-c l o) I get pdf file opened in separate application.

For pandoc export to docx I do the 'same' (to docx and open C-c p x) but result file is opened in emacs itself with binary data and all the inner stuff of that file.

How can I tell emacs to open it in msword instead?


texts: magit-define-popup-switch not enabled by default

texts:
I'm trying to teach magit that git pull --rebase should always --autostash.  pull --rebase is always my default, so I want --autostash to be the default as well.

The 5th argument of magit-define-popup-switch is documented as

If optional ENABLE is non-nil, then the switch is on by default.

however, when I do

(magit-define-popup-switch 'magit-pull-popup ?A "Autostash" "--autostash" t)

the switch is not on by default.  I get the same behavior when I simply do

(magit-define-popup-switch 'magit-pull-popup ?A "Autostash" "--autostash")

What am I misunderstanding?


texts: Can I display a character as if rotated?

texts: Suppose that I'd want to display a character as if rotated by 90 or 180 degrees in Emacs. Is there a way to go about that?


texts: How to discover (standard) function names?

texts:
When programing emacs (or common) lisp, how to discover (standard) function names (using emacs and working offline)?

Example: Let's say you want to shift bits of an integer, but you don't now the name of the function, which can do this (hint: the name is ash, but you don't know, yet).
apropos isn't helping you, because it does not list ash when asking for shift.


texts: How to get a major mode to open full screen

texts: I'd like magit to default to a large buffer instead of one that is half the size of the available space. Even better would be a way to wrap the call to a major mode to make this happen when opening any major mode?


texts: Can't use eval-replace-last-sexp in multiple-cursors

texts:
In scratch file I has:
(* 60 10)
(* 50 100)
(* 50 200)

I want to use my custom function replace-last-sexp  (C-c C-l)
(defun replace-last-sexp ()
(interactive)
(let ((value (eval (preceding-sexp))))
  (kill-sexp -1)
  (insert (format "%S" value))))

To do this I use multiple-cursors package - https://github.com/magnars/multiple-cursors.el
After I press C-c C-l in multiple-cursors mode I get this:
600
(* 50 100)
(* 50 200)

Why not calculate another lines?


texts: Connect to remote Windows machine: Network error: Connection timed out

texts:
Windows 10 (64 bit), Emacs 25.1

When I want to connect to remote Windows machine (via VPN) I use the next steps:

Start application OpenVPN and success connect
Start msc (Remote Desktop Connection)
Input ip address (193.178.6.32)

As result I success connect to remote Windows machine. OK.

So I want to connect to same remote Windows machine by Emacs.

My steps in Emacs:

Find file (C-x C-f)
/193.178.6.32:

But I get error on buffer tramp/pscp 193.178.6.32

plink   -ssh -t 193.178.6.32 " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh " && exit || exit
FATAL ERROR: Network error: Connection timed out


texts: How to determine if there is really any delay in text input with company completion?

texts:
I use Company mode as completion. I like the gratification of instant completion popups. So I set the following setting:

(setq company-idle-delay 0.0)

So basically no delay before the pop-up appears.

However, I noticed someone said it would slow down the text input. When Googling around, I found no way to determine how this will delay the input of text. Any suggestion in order to determine the setting above will really delay the text input?


texts: yassnippet snippet to insert current timestamp

texts:
I would like to create a yasnippet snippet which will insert automatically the current timestamp. I have found a code which actually prints the timestamp but I do not know how to integrate into a yasnippet snippet.
Any way to do this?

Example. I would like that pressing "weather" and then TAB I get
2017-07-29, time =
so I can type the weather.


texts: org-mode / export to PDF: How to disable numbering for pages?

texts:
When I export a simple text file to PDF with the command org-latex-export-to-pdf, by default, Org-mode adds the number of each page at the bottom of the PDF file.

But I would like Emacs to print absolutely no page number.

How could I do that?


texts:
I was not the only one who thought ido is very inconvenient when trying to write a new file. The emacs wiki has a section dedicated to disabling ido for write-file:

Disable ido mode for particular commands, e.g. write-file

Their suggestion is to turn off ido for write file using:

 (define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil)

This does not seem to work for me. ido still runs when I hit C-x C-w. Any suggestions?


texts:
I read the official documentation.
Here's what not clear:

Scope: If I do a setf in a function, is that visible in another function.
Undo: How do I undo it.

in ruby, you can do

def myfunc
  a = "foo"
end

so is (setf a "foo") equivalent to a = "foo" ?


texts:
Recently, when editing files in LaTex, upon pressing TAB, I get a huge indentation. Instead, the default behavior used to be to align with respect to previous environment definition. :
I start with this (Example 1):
\begin{align}
\begin{split}
F = ma
\end{split}
\end{align}

Upon pressing TAB in the second row I get something like (Example 2):
\begin{align}
                                 \begin{split}
F = ma
\end{split}
\end{align}

Whereas I would like to just smash the TAB button to get (Example 3):
\begin{align}
   \begin{split}
     F = ma
   \end{split}
\end{align}

Example 3 is what used to be the case but I might have broken something and I don't know what. Now I get Example 2. Also, if I hit the TAB outside of the align environment, I get a huge (12 spaces) displacement, which is also bizarre (previously it wouldn't do that).
I tried adding the following suggestions into my .emacs file:

Suggestion in the question and first answer of Confusion by the usage of indent-tabs-mode nil
The suggestion in Why is emacs indenting with tabs even though indent-tabs-mode is nil?


texts: How to copy or move code in current scope to end of another file

texts:
I find myself refactoring code fairly frequently and my screen space is at a premium. I'd like to be able to move to a particular scope (class, function, or even if-statement/for-loop blocks) and either cut the code and append it to another file or copy the code and append it to another file. Ideally, I'd like to do this in Fortran, C and C++.

I know I can open multiple windows and stack them and use the usual kill on lines or marked regions then change to the other window and yank the lines or regions into that buffer. But I don't want to have multiple windows open, it makes it harder to see where I am in the file from which I'm moving code. Plus, code from one file may be going to multiple places. So I'd like to just dump it at the end of a a different file and then move it around in that file later.

How can I move/copy the code within the scope of the cursor to the end of another file for those languages? If there isn't a method that would work in each language, is there a way to do it on marked regions of code and single lines?


texts:
I am trying to emulate buffer-specific keybindings using minor modes as described here.

For an arbitrary buffer, I am trying to call this function:

(defun buffer-set-keys ()
  (interactive)
  (cl-flet ((foo () (insert "a")))
    (define-minor-mode this-buffer-local-mode
      :init-value nil
      :key-map '((kbd "M-_") . foo))
    (this-buffer-local-mode)))

I'm pretty sure I'm doing something wrong, and in any case when I try M-_ I get that "M-_ is not defined". How can I get this right?


texts: Accessing login-shell variables (from counsel-find-file)

texts:
With #'counsel-find-file, I can type $ to access environment
variables, but it appears these belong to a special emacs environment
and are not login-shell-wide.  Can I access the latter kind of variable
as well?


texts:
I have emacs 27 on MacOS running in -nw mode.
I have prelude installed. It comes with projectile.

I regularly work on two git repos in my disk.

~/client1/
~/client2/

In any given day, I would open files in both those folders.
When I press C-x C-b, my list is littered with files from both
my clients, and it would be cool to see a "project based" view
of it.

The projectile GitHub readme says I can "switch between projects you have worked on". How?

That same readme also links to a plugin "https://github.com/bbatsov/persp-projectile", that also seems to do what I need. If that's a better option,
how do I use it?

FYI "C-x C-b runs the command ibuffer (found in global-map), which is an
interactive autoloaded compiled Lisp function in ‘ibuffer.el’."


texts: How to select text found by `re-search-forward`?

texts:
The following function searches buffer text for string STR, in the same way as search-forward. How to modify it in order that it selects the text found?

(defun my-search-forward (str)
  (interactive "smy-search-forward: ")
  (re-search-forward str nil t))


texts: What does the "Mark set" message mean when going to the beginning or end of the buffer?

texts:
Opening emacs -Q, then Pressing Ctrl-Home or Ctrl-End also shows this message.

Mark set

What is happening? Why is the mark set and is there a way not to set the mark?


texts: I have set Emacs to alert me via a window 30 minutes before an appointment. This is working as expected. However, every three minutes thereafter, Emacs continues to alert me to the same appointment. How do I dismiss/acknowledge the reminder and prevent it from triggering repeatedly?


texts:
I know I can use a Greek input method, but what I want is quite different: how to use Emacs in an OS configured for Greek, without having to set the keyboard to English (or any other Latin alphabet language) when wanting to use Emacs.

I know I can set my own keybindings, but it is not practical.  Should I just do so and create an ELPA package for Greek keybindings?


texts: Ignore tags in `org-end-of-line` and similar motions

texts:
Is there a convenient function for jumping to the last non-tag character in the line of an org-mode heading? For instance...

* This is |my header     :tag1:tag2:

I would like a command that moves the point (|) to:

* This is my header|     :tag1:tag2

Ideally, I would love something that implements a full set of evil motions for this, so that commands like dg_ will not delete tags.


texts: How can I make it so that H-g followed by a gives an alpha etc.?


texts: Can I copy a date from M-x calendar into kill ring or buffer

texts:
I would like to be able to run M-x calendar, navigate to a date, press some keystroke which would do one of the following:

place the selected date onto the kill ring

or

close the calendar and insert the selected date into my current buffer.

Is there any built-in functionality for this?


texts: setting default columns in org column mode into init file

texts:
Trying to set preferred columns in ORG column mode.
this works perfectly if I put it on head of the file:

#+COLUMNS: %45ITEM %TAGS %PRIORITY %TODO %CLOSED %SCHEDULED

But I avoid to repeat it for every org file and tried to put it on init file, to no avail:

(setq org-agenda-overriding-columns-format "%45ITEM %TAGS %PRIORITY %TODO %CLOSED %SCHEDULED")


texts:
When I do M-x package install, (with a space between the words) I get:

I'd like the "package-install" option to be prioritized over "package-menu-mark-install". What can I do to accomplish this?


texts: Persist variables (and maybe input history) across restarts

texts:
Sometimes I wish to persist the value of some variable when I quit emacs. For example, I would like to do this for compile-command.
Now, I guess I could find the hook that is run when Emacs quits (assuming there is one, a quick scan through the list of hooks did not turn up an obvious candidate) and save that variable to a file of my own; and reload it in init.el. But surely someone else had the same need already. Is there a package or even some inbuilt way to achieve this?
Bonus question: it would be awesome to also be able to save the history of the same. I.e., when I type M-x compile, I can scroll back through the previous compile commands. Would be great to keep that. Same for M-! with shell commands and so on.


texts: python-mode: tab always indents with 2 spaces

texts:
I start up my Emacs25 with emacs25 -Q to skip any init.el. When I then open a python file with local file variables as shown below, TAB indents only two spaces, instead of four:

# -*- mode: Python; python-indent-offset: 4; python-guess-indent: nil

for i in range(0, 10):
  print i

def f( i ):
  print i

What do I need to do, to get python-mode to honour the python-indent-offset?


texts: How to do case-insensitive rgrep for cyrillics?

texts:
I tried to use rgrep to search in cyrillic files with UTF-8 encoding (M-x rgrep command with search query бонус), the resulting command name was

  /usr/bin/find . -type d ( -path */SCCS -o -path */RCS -o -path */CVS -o -path */MCVS -o -path */.src -o -path */.svn -o -path */.git -o -path */.hg -o -path */.bzr -o -path */_MTN -o -path */_darcs -o -path */{arch} ) -prune -o ! -type d ( -name .#* -o -name *.o -o -name *\~ -o -name *.bin -o -name *.lbin -o -name *.so -o -name *.a -o -name *.ln -o -name *.blg -o -name *.bbl -o -name *.elc -o -name *.lof -o -name *.glo -o -name *.idx -o -name *.lot -o -name *.fmt -o -name *.tfm -o -name *.class -o -name *.fas -o -name *.lib -o -name *.mem -o -name *.x86f -o -name *.sparcf -o -name *.dfsl -o -name *.pfsl -o -name *.d64fsl -o -name *.p64fsl -o -name *.lx64fsl -o -name *.lx32fsl -o -name *.dx64fsl -o -name *.dx32fsl -o -name *.fx64fsl -o -name *.fx32fsl -o -name *.sx64fsl -o -name *.sx32fsl -o -name *.wx64fsl -o -name *.wx32fsl -o -name *.fasl -o -name *.ufsl -o -name *.fsl -o -name *.dxl -o -name *.lo -o -name *.la -o -name *.gmo -o -name *.mo -o -name *.toc -o -name *.aux -o -name *.cp -o -name *.fn -o -name *.ky -o -name *.pg -o -name *.tp -o -name *.vr -o -name *.cps -o -name *.fns -o -name *.kys -o -name *.pgs -o -name *.tps -o -name *.vrs -o -name *.pyc -o -name *.pyo ) -prune -o  -type f ( -iname *.org ) -exec grep --color -i -nH -e \б\о\н\у\с {} +

As you can see the search term was quoted with slashes \б\о\н\у\с, and inspite of -i option to grep the result was case-sensitive, e.g. lines with бонус were found, but Бонус or БОНУС were not. Of course I can use regexp in search query, but I'd like to avoid this for convenience reason.

How to make such a search really case-insensitive?

I use GNU Emacs 25.3.1 (x86_64-unknown-cygwin) of 2017-09-12 (emacs-w32.exe from cygwin installation) on Windows 7. BTW, the same case-sensitive results I get when use grep -i бонус *.org in shell under emacs, while in cygwin shell the result is correct.

UPD: Execution of locale command in emacs shell result in the following:

sh-4.4$ locale
LANG=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=

It seems my locale settings are broken...


texts:
Whenever I double-click files on finder to open them using emacs, they open in existing buffers. Instead I would like them to open in separate frames by default.

It seems as though many others have also queried this issue on StackExchange but I still haven't been able to find a satisfactory answer.

I've been trying to use display-buffer-alist and display-buffer-pop-up-frame but the documentation for this is very confusing and I couldn't find the right phrasing for my init.el file.

I'm using OS X El Capitan 10.11.3, and Emacs 24.5.1 with this version: https://github.com/railwaycat/emacs-mac-port


texts: inserting passwords into pass from shell-mode

texts: I'm trying to manage my passwords using the pass script from shell-mode inside Emacs. The script prompts me to enter the password twice as is customary when adding or changing passwords. The first time it asks for the password, Emacs successfully hides it, placing little dots in the message area. This is the desired behavior. Unfortunately, the second time it asks for the password, Emacs happily prints the characters to the shell-mode buffer. Is there a configuration setting I can add to make sure it hides the password both times?


texts: What are the thoughts behind evil-move-cursor-back?

texts:
In Evil, there is the variable evil-move-cursor-back. This is what it's documentation says:

  "Whether the cursor is moved backwards when exiting Insert state."

Now, by default, it is set to t . The effect this has is that, if you enter Insert state and then immediately leave it (switch to Normal state), the cursor is moved back one character compared to where you started off. I understand I can change this behavior by changing the value of the variable, but as a beginner Evil and Vim user I am afraid I will not gain the benefits of having it enabled still.

So, does anyone know the background or thinking of this variable or the behavior it controls?


texts: disable company-mode completion inside comments

texts:
This is something that's been bothering me for  a while. I think I've configured company-mode backends wrong as I'm also getting company backends when inside comments.

Here is my company-mode config file.
And here is an example of how I enable company-mode for specific major modes using a local variable for company-backends and adding that to the major mode hook. Like so:-

    (defun my-racer-mode-hook ()
      (set (make-local-variable 'company-backends)
           '((company-capf company-files company-yasnippet))))
    (add-hook 'racer-mode-hook 'my-racer-mode-hook)

I configure other major modes very similarly to the snippet above. But, I feel I did a mistake somewhere that's making company-yasnippet to pop up in the comments also. Can someone please point out where I did wrong ?

EDIT: I get completion from all backends inside the comments, not just company-yasnippet. Sorry for the confusion.


texts: apostrophe in org-babel export to latex and beamer

texts:
How can I get org-babel to properly render ' and not ’ when exporting to LaTeX and to Beamer?
I didn't find any good solution yet, and I would like the code to be copy-pasteable.


texts:
Do frames in emacs have a handle the way buffers do? In particular, can I specify that a particular file should be opened in a specified frame? I would like to have two frames where I use one for development and use the other to read documentation and browse tags.

(Tagging the question with emacsclient and linux because I am ok with an answer which requires them.)


texts: Custom agenda view based on effort estimates

texts:
I have currently a very simple custom agenda view, which displays a daily view, important tasks (those tasks with priority A), and pending tasks (those tasks whose todo keyword is WAITING).
I would like to add another category in this agenda view, which would be the "quick picks", i.e. those tasks whose effort estimates are lower than 0:15.
Until now, I have only managed to filter the tasks whose effort estimates are exactly equal to 0:15, and I struggle to find an easy solution for all tasks inferior to 0:15.
Here is the piece of code I use:
(defun perso/quickpick (arg)
  "Display entries that have effort estimate equal to ARG."
    (org-tags-view t
                   (format "Effort=\"%s\"" arg)))

(setq org-agenda-custom-commands
      '(("d" "Custom daily agenda"
         ((agenda "" ((org-agenda-span 'day)))
          (tags "PRIORITY=\"A\""
                ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
                 (org-agenda-overriding-header "Important tasks")))
          (todo "WAITING"
                ((org-agenda-overriding-header "Pending tasks")))
          (perso/quickpick "0:15"
                     ((org-agenda-overriding-header "Quickies")))))))

Is there a simple solution to adapt perso/quickpick and/or org-agenda-custom-commands to get what I want?
Thanks!

Addendum: A MWE org file with one item per category:
#+PROPERTY: Effort_ALL 0:05 0:10 0:15 0:20 0:30 0:45 1:00 1:30 2:00 3:00

* TODO Wash the car
SCHEDULED: <2020-07-01>

* WAITING Fix a bug

* TODO A quick task
  :PROPERTIES:
  :Effort:   0:15
  :END:

* TODO [#A] An important task


texts: How does emacs `shell-mode` know to prompt for sudo?

texts:
In shell-mode, a command like sudo CMD opens up a prompt in the echo area saying:

[sudo] password for root:

How does it know to do this? AFAIK, this behaviour cannot rise out of simply running sudo as usual, because the read builtin does not create such a prompt.


texts: Org tags, Org properties, or ? for SRC and VERSE blocks

texts:
I'm writing a musical in collaboration with a composer. We're using
org-mode, but neither of us is an expert. I'm using #+SRC blocks for
occasional Lilypond code and #+VERSE blocks for lyrics, viz:

** SCENE II

description, dialogue, etc. description, dialogue, etc. description,
dialogue, etc. description, dialogue, etc. description, dialogue, etc.

#+NAME: song-name
#+BEGIN_VERSE
 la la la
 la la la
#+END_VERSE

#+NAME: song-name-melody
#+BEGIN_SRC lilypond :file song-name-melody.pdf
<< {
  /key d /major
  /time 3/4
  a4 a a |
  a4 a a |
 }

/addlyrics {
la la la |
la la la |
 }
>>
#+END_SRC

more description, dialogue, etc. description, dialogue, etc.
dialogue, etc. description, dialogue, etc. description, dialogue.

** SCENE III
etc.

I'd like my collaborator to be able to easily view just the lyrics, or just the Lilypond code. My first thought was to use TAGS or PROPERTIES, but because these blocks aren't headlines that doesn't seem possible.

How could this kind of narrowing (if that's the right term) be easily achieved?


texts: How to prevent stuff from being exported

texts:
I want some stuff to be visible in the editor, but not in the export (C-c C-e). Some stuff includes headlines. I tried this:

#+EXPORT_FILE_NAME: ~/Documents/Outbox/hide
#+OPTIONS: ^:nil
#+STARTUP: indent
#+STARTUP: hideblocks
* Foo
  :DRAWER:
  - `M-x org-insert-drawer` for stuff to be hidden.
  - Unfortunately, you can't put a subtree in it, AFAIK
  - Besides, this does get exported.
  - What is meant by hidden, then?
  :END:

#+BEGIN_HIDE
You can't hide, or can you?
#+END_HIDE

And that's what I get from C-c C-e l l:

\section{Foo}
\label{sec:org2b52cc8}
\begin{itemize}
\item `M-x org-insert-drawer` for stuff to be hidden.
\item Unfortunately, you can't put a subtree in it, AFAIK
\item Besides, this does get exported.
\item What is meant by hidden, then?
\end{itemize}

\begin{HIDE}
You can't hide, or can you?
\end{HIDE}
\end{document}

Manual:

Drawers


texts:
I want to add a markup and formatting for such markup, i.e. <kbd>...</kbd> with a box surrounds such markup. I also want the mark up to be compatible with (setq org-hide-emphasis-markers t). That is, when the variable is set to t, the <kbd> and </kbd>tags should disappear, leaving the text between it with the specified formatting above.

The answer posted in this question: How to highlight text permanently in org-mode does not solve this problem, since it is only applicable for existing markups, not extending Org with new markups.


texts: Is there a package to send a piece of text to shell and get the result back?

texts: I want to know if there is a package to send a piece of text to shell commands like sed, awk or other text processing utilities and then get the result back to emacs? Thanks.


texts: How to make frame-title-format persistent?

texts:
When I set the title for a frame to current buffers filename via (setq-default frame-title-format '("%b")) the title often falls back to "emacs@" system-name, when the frame is inactive.

I'd expect emacs to keep frame-title, when a frame is inactive, too.

How to keep the title at all times – and only change it, when an other buffer is active? What could cause the unwanted behaviour?

EDIT:
Ideal would be, if I could just keep frame-title-format '("%b") – but inactive Frames shouldn't revert to "emacs@" system-name, but keep the filename from active buffer.


texts: can't get company-reftex-labels to work properly

texts:
I have tried to set the company-backend as described on their github page and did not end up with the sweet resulting pop-up completion, in ref as in their image
My image:

their image:

What am I doing wrong?
My relevant configs are as follows
(defun require-package (package &optional min-version no-refresh)
  "Install given PACKAGE, optionally requiring MIN-VERSION.
     If NO-REFRESH is non-nil, the available package lists will not be
     re-downloaded in order to locate PACKAGE."
  (if (package-installed-p package min-version)
      t
    (if (or (assoc package package-archive-contents) no-refresh)
    (package-install package)
      (progn
    (package-refresh-contents)
    (require-package package min-version t)))))

(require-package 'company)
(add-hook 'after-init-hook 'global-company-mode)
(eval-after-load "company"
  '(add-to-list
    'company-backends
    'company-auctex
    'company-jedi
    'company-math
    'company-reftex-citations
    'company-reftex-labels
    'company-shell
    )
  )
(setq company-dabbrev-downcase 0)
(setq company-idle-delay 0)

(require-package 'company-reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
(setq reftex-plug-into-AUCTeX t)

Cheers!


texts: How to delete backward word in find-file using ido?

texts:
I was using regular find-file, and have a current setup to delete a word, which was working inside find-file.

(defun backward-delete-word (arg)
  "Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
  (interactive "p")
  (delete-region (point) (progn (backward-word arg) (point))))

(global-set-key "\C-o" 'backward-delete-word)

When I switch to ido via (ido-mode 1) word deletion does not work in ido-find-file minibuffer.

[Q] Is there any way to do backward word deletion in ido-find-file?


texts:
I am trying to open files in Emacs using dired.  But whenever I open pdf files, the doc viewer in Emacs keeps loading the document.  Is there any
way to stop the pdf files being opened in Emacs buffer?


texts:
I have proselint setup like here, i.e.:

(flycheck-define-checker proselint
  "A linter for prose."
  :command ("proselint" source-inplace)
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": "
        (id (one-or-more (not (any " "))))
        (message) line-end))
  :modes (text-mode markdown-mode gfm-mode))

(add-to-list 'flycheck-checkers 'proselint)

How can I extend it to message-mode? Just adding message-mode to the list of modes above is not enough.


texts: Why is C-i executing TAB instead of evil-jump-forward?

texts:
For some reason, pressing ctrl+i is sending a TAB command instead of executing evil-jump-forward. Viewing the lossage, I see:

C-o [evil-jump-backward]
TAB [c-indent-line-or-region]

From describe-bindings I see:

 <C-i>      evil-jump-forward

I've even updated my .spacemacs file:

  (global-set-key (kbd "C-i") 'evil-jump-forward)

..but this has the same result. Any ideas on what could be the issue?


texts: How do I run elisp code on a filtered email in Gnus?

texts:
I am downloading mail using fetchmail from a pop account and using gnus to read mails from the maildir.

I would like to run elisp code on emails that are matched by fancy split rules, or something similar.

My end goal would be to match all mails from export@client.com and run elisp code to extract the data and upload it to a server.

I have read the linked manual and got the idea after reading this portion

(! func split)
If the split is a list, and the first element is !,
then split will be processed, and func will be called as a
function with the result of split as argument. func should return a split.

Would I be able to use the function to run code for the side effects and still return the split, or am I on the completely wrong track?


texts: What's the value of default-directory during startup?

texts:
I'm looking through startup.el, and normal-top-level-add-subdirs-to-load-path references the default-directory variable.

What's the value of that variable during startup? I searched for calls to normal-top-level-add-subdirs-to-load-path and only found a 2-line file site-lisp/subdirs.el

(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
    (normal-top-level-add-subdirs-to-load-path))

I tried inserting some debugging statements to get more insight, but so far they haven't worked. First I tried adding:

(message "%s" default-directory)

and byte recompiling the file. Restarted Emacs but I saw no trace of my debugging in the Messages buffer. Then I replaced the above line with:

(with-temp-file "/Users/ivan/emacswhereami"
  '(insert default-directory))


texts:
Q: how can I change the syntax of a character for a single function?

In text-mode and its derivatives, the ' character has word syntax rather than, say punctuation or string quote syntax.  That's a problem when using abbrev-mode, as I would like the ' character to fire the abbrev when I'm using a possessive.

For example, if the abbrev "pres" expands to "president" and I want to write the "president's cat", I'd expect to be able to type p r e s ' s, where "pres" expands automatically to "president" when I hit '.

Now: I don't want to change the syntax for ' globally or permanently, because I don't want to interfere with any other functions that depend on ' having word syntax.  I tried the following:

(defadvice self-insert-command (around testing activate)
  (with-syntax-table (copy-syntax-table (syntax-table))
    (modify-syntax-entry ?' "\"")
    ad-do-it))

Two problems.

First: although it does fire the abbrev as expected, smartparens-mode complains every second time the abbrev fires (really: it's every second time).  That's a tangent on the main point, however.

Second, and more importantly: this advice seems awfully costly for a function that gets invoked on every insertion command.  It calls up the syntax table, copies it, modifies it, uses it, and then restores the original syntax table.  That seems awfully silly when I really only care about one character, which leads me to suspect I'm going about this wrong.

Is there a smarter way to do this?  (Note that I'm most interested in temporarily changing the syntax of a character and am using the abbrev example to motivate it.)


texts: Understanding precedence of minor modes keymaps

texts:
I would like to understand when keymaps of minor modes get "applied" and how do they get applied exactly? In particular, is there a way to see a list of a active minor-mode maps? I know I can look the list of active minor-modes and check which of them has a keymap, but I am looking for a deeper understanding of the mechanism).

One reason I want to understand this is to figure out what happens when I have multiple minor modes mapping the same key sequence. Which one gets precedence and how can I influence this?


texts: For MacOS: how to bind left and right option keys separately?

texts:
Using Gnu Emacs in MacOS "El Capitan".

Question:

How do I bind the right option key to control but keep the left option key bound to option?

Background:

I found that even with caps_lock as control my left hand would start to ache, so I decided to have as many control keys as possible.  Before switching to Mac I never used caps_lock or option (still don't use caps_lock), so I bound both of them to control: caps_lock to control in the Keyboard systems preferences and option to control in my .emacs file.

Unlike PC keyboards, the Apple keyboard has only one control key but two option keys (one on the outside of each of the two command keys):

But now I'm finding that I would like to be able to have an option key in Emacs.  There is already a control key on the bottom left but not one on the bottom right, so ideally I would revert just the left option key (now mapped to control) back to option But I still want the right option key to be a control.

These are the relevant lines from my .emacs file.

(setq
  mac-option-key-is-control t
  mac-option-modifier 'control
 )


texts: how to modify command to open buffer in new tab instead of new window

texts:
Emacs-27.1 ships with a new tab-bar-mode minor mode.  This puts a tab bar at the top of each Emacs frame.  Each tab in the tab bar can display multiple windows.
Emacs (and various packages) has many commands that open a buffer in a new window in the current frame.
How do I take an existing Emacs command that opens a buffer new window in the current frame and instead make it open a buffer in a new tab?
For instance, I often call the Magit function magit-status.  This function opens a new window to show the Magit status buffer.  Instead of opening a new window, I'd like to open a new tab to show the Magit status buffer.
What are my options for opening buffers in new tabs instead of new windows?
I can imagine two general approaches:

Change some Emacs variable that makes all new windows open in new tabs.  This would be an easy way to have all commands open buffers in new tabs, although quite heavy-handed.
Is there an Emacs variable I can set that will do this?

Create a function like open-in-new-tab that modifies any function given as an argument to open a buffer in a new tab instead of a new window.
For instance, if I want magit-status to open in a new tab, I would have to call it like (open-in-new-tab 'magit-status).  I could create a command for this, and bind it to some key.
How would I write this open-in-new-tab function?  (I'm somewhat new to Elisp.)
I imagine this open-in-new-tab function would be similar to a function for modifying a command to open a buffer in a new frame instead of a new window.


texts:
I want to navigate between the lines of a file based on indentation. The file is structured by indentation: a line that's more indented than the previous line is a child of the previous line, a line that has the same indentation as the previous line is its sibling. I'm mostly looking for three commands:

Move to the next sibling, i.e. the next line with the same indentation, skipping lines that are more indented, but not skipping past a line that is less indented.
Move to the previous sibling, i.e. the same thing in the other direction.
Move to the parent, i.e. to the previous line with less indentation.

The column position of the point should not change.

These are analogs for indentation-structured data to forward-sexp, backward-sexp and backward-up-list for sexp-structured data. Indentation corresponds to program structure in languages such as Haskell and Python; these functions can be especially useful in this context but I am not looking for anything mode-specific (my primary use case is intendation-structured data inside another file format).

Coloring indentation levels can help to navigate manually with Up/Down but I want something automatic.

This super user question is similar but with weaker requirements and does not currently have answers that meet my requirements.


texts: Emacs failing to access HTTPS URL behind a proxy

texts:
I hoped that this problem's solution would solve it for me, but it didn't.  I've got my proxy set up as follows (slightly redacted):
(setq url-proxy-services
       '(("no_proxy" . "^\\(localhost\\|10.*\\)")
         ("http" . "proxy.xxx.com:8080")
         ("https" . "proxy.xxx.com:8080")))

and when I use eww to make a request I get (again, slightly redacted):
Request Error: https://www.google.co.uk/
XXX Dynamic IT

         Request Error (invalid_request)

      Proxy: xxx-xx-20

      Url: https://www.google.co.uk/
      Time: [11/09/2020:08:46:35 GMT]
      Client: xxx.xxx.8.32
     Your request for https://www.google.co.uk/ could not be processed. Request
     could not be handled
     This could be caused by a misconfiguration, or possibly a malformed
     request.

I was wondering if this could be because it's trying to talk HTTPS to the proxy.  I tried following the example on EmacsWiki where the protocol is included in the proxy specification, so I'd instead have:
(setq url-proxy-services
       '(("no_proxy" . "^\\(localhost\\|10.*\\)")
         ("http" . "http://proxy.xxx.com:8080")
         ("https" . "http://proxy.xxx.com:8080")))

but this doesn't work either.  I get a couple of lines in the *Messages* buffer that suggest I shouldn't be doing it that way:
Contacting host: http:80
open-network-stream: http/80 Temporary failure in name resolution

Am I doing something wrong and/or daft?
Thanks in advance.


texts:
I often have to make several substitution of the same string:

(format "%s %s %s" "a" "a" "a") ;; gives: "a a a"

(it's just a dummy example, in this case it's better to glue "a" with a whitespace, but in general I deal with more complicated situations)

Is there a way to make a named substitution? For example in python one would write:

"{0} {0} {0}".format("a") # or:
"{name} {name} {name}".format(name="a")


texts: set the pgp signing marker to the top of the new message

texts:
I try to switch from notmuch mail to Gnus (since the notmuch setup is too komplex; keeping the tags synchronized across three devices is very hard; and due to work requirements I have to move messages with a specific tag to a specific folder; much too complex). In notmuch I wrote this little snippet to always sign messages with GnuPG:

(defun ck/sign-message ()
  (interactive)
  (goto-char (point-min))
  (search-forward "--text follows this line--")
  (end-of-line)
  (insert "\n")

  (mml-secure-message-sign-pgpmime))

(add-hook 'message-setup-hook 'ck/sign-message)

This ensures that the signing marker is always the first thing in the new message since mml-secure-message-sign-pgpmime searches for the first newline and then inserts the marker.

But since Gnus yanks the text after the message-setup-hook gets executed. I now end up with the signing marker after the quoted message.

Is there a hook that gets executed after the yanking? I could not find one, but maybe I’ve been overseeing it? If not: is there a different solution for this problem?

I’d like to have the marker directly below the --text follows this line-- marker and the quoted text below.

Best regards,


texts: How can I get all file links in one org-mode file?

texts:
There are some local file links existed randomly in my org-mode file. most of them are image links, like (file:images/samples.png) along with some other urls. What I want to do is that parse all these links from the file and store them in a lisp list for afterwards use.

Here is a sample file:

* headline1
  [[file:images/sample1.png][description1]]
* headline2
  [[file:images/sample2.png][description2]]
  [[http://www.google.com]]

After parsing, a list of all file links should obtained.

(list "images/sample1.png" "images/sample1.png")


texts:
I would like to do the equivalent of this

vnoremap p "_dP

in evil-mode. (i.e. I would like paste-replacing to not yank).
I want to do the same for c C and P.

I tried this:

(define-key evil-visual-state-map (kbd "p") (kbd "\"_dP"))

but it just deletes the selection without pasting.

Is there any way to do this?


texts: Greek typing & spell-checking with hunspell: encoding issue?

texts:
hunspell-checking Greek text I create in Emacs is not working.

Notes:

I am aware of this post: Spell check with multiple dictionaries
Eventually, I want to use ispell with hunspell in Emacs, which is also currently not working, I guess due to the problem described below.

Let me show my setup so far:

I downloaded a Greek dictionary from this page,
https://sourceforge.net/projects/orthos-spell/files/v.0.4.0./orthos-el_GR-0.4.0-87.oxt/download,
and extracted and installed the 2 relevant files:

$ unzip -x orthos-el_GR-0.4.0-87.oxt dicts/el_GR.dic dicts/el_GR.aff
$ sudo mv * /usr/share/hunspell/

$ hunspell -D
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
...
/usr/share/hunspell/el_GR
...
Hunspell 1.3.2

For testing on the command line, I copied and pasted a word from the dictionary /usr/share/hunspell/el_GR.dic. Spell checking works fine.

$ echo "άλφα" | hunspell -d el_GR
Hunspell 1.3.2
*

Now to Emacs: First I set the input method to greek-babel.

M-x set-input-method greek-babel

Now I can type alfa (the ά I get by ' followed by a):

άλφα

But pasting this into the hunspell commandline call, the word alfa with this accented a is not recognized:

$ echo "άλφα" | hunspell -d el_GR
Hunspell 1.3.2
& άλφα 1 0: άλφα

A quick test in python shows that the accented as are different characters:

$ python
Python 2.7.13 (default, Jan 03 2017, 17:41:54) [GCC] on linux2
> ['ά'], ['ά']
(['\xce\xac'], ['\xe1\xbd\xb1'])

What am I missing?


texts:
The beginning of my ~/.emacs.d/init.el file looks like this:
;; MELPA
(require 'package)
(setq package-enable-at-startup nil)
(setq package-check-signature nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("elpy" . "https://jorgenschaefer.github.io/packages/"))

;; boostrap 'use-package'
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(use-package windmove
  ;; move cursor between windows
  :demand
  :bind
  (("C-<left>" . windmove-left)
   ("C-<right>" . windmove-right)
   ("C-<up>" . windmove-up)
   ("C-<down>" . windmove-down)))

... more stuff ...

I am trying to byte compile my init.el file. I execute the following in the terminal, sinde the ~/.emacs.d/ directory:
$ emacs --batch --eval '(byte-compile-file "init.el")'

The output is:
In toplevel form:
init.el:59:1:Warning: ‘("C-<left>" . windmove-left)’ is a malformed function
init.el:59:14:Warning: reference to free variable ‘windmove’
init.el:62:3:Error: Wrong type argument: sequencep, windmove-right

Basically, the very first key binding definition fails... and there is also some sort of warning about a free variable. How do I properly byte-compile the init.el file - even for the above very simple example (imagine there's nothing else to the init.el file)?


texts:
I'm using auth-source-search to retrieve passwords from ~/.authinfo.gpg. According to the documentation I may have to unwrap the secret property because it's in a function.

(let ((secret (plist-get found :secret)))
            (if (functionp secret)
                (funcall secret)
              secret))

But in my case the password is somehow wrapped in two functions, so I would have to retrieve it with:

(funcall (funcall secret))

This would result in very ugly code.

(let ((secret (plist-get info :secret))
    (if (functionp secret)
        (if (functionp (funcall secret))
            (funcall (funcall secret))
        (funcall secret))
    secret)))

Is there a more elegant way to solve this problem?


texts:
I copy text from websites and paste/yank into emacs buffers. But this text sometimes has silent hyphens in them. The behaviour when copying and pasting text with soft hyphens in it varies across applications, but for emacs (on Windows), it seems to paste the text including the soft hyphens. I want it to not include the soft hyphens.
What I've been doing right now is a manual M-x replace-string where I paste in the soft-hyphen to be replaced with nothing.
Is there a way to have emacs automatically replace soft-hyphen with nothing after a yank? Is there a hook to use?


texts: How to get shell mode to properly handle my PS1, which involves user-defined function calls?

texts:
My bash_profile includes a couple functions to build the prompt. This is a super-simplified version, which I'm using to try to debug the problem with:

custom_git_function () {
  echo "git"
}

build_custom_prompt() {
  export PS1="\u:\W \$(custom_git_function) >"
}

build_custom_prompt

When I run shell mode in emacs, it seems to have access to build_custom_prompt, but not custom_git_function.

bash: custom_git_function: command not found

What's a clean way to fix this?


texts: In mmm-mode can you have several classes for the same mode?

texts:
In my code I have the following to delimit regions that initiate/end whatevz-mode:

(require 'mmm-mode)
(setq mmm-global-mode 'maybe)

(mmm-add-classes
  '((whatevz
          :submode whatevz-mode
          :front ".*whatevz\(\"\"\""
          :back ".*\"\"\"\)")))

(mmm-add-mode-ext-class 'whatevz-mode nil 'whatevz)

I want to add several possible snippets that delimit whatevz-mode (The above only shows whatevz("""). Do I have to add that to the add-classes   above - creating a much more advanced regex - or can I call mmm-add-classes again with another simple regex?


texts: Is this a c-default-style? If not, how can i configure it?

texts:
I've just started using spacemacs and the docstrings for cc-styles are a bit daunting. I've also just started working on a new project in c, and would like to keep consistent with existing style:

struct map_s
{
  uint8_t     (*key_hash   )(const void* key);
  bool        (*key_match  )(const void* a, const void* b);
  const void* (*item_key   )(const void* item);
  void        (*item_delete)(void* item);

  map_node_t* base[256];
};

My question is, is this a style already implemented as one of the c-default-style options? If not, can anyone give me pointers on specifically how to get the cc-styles package to add the padding in the function pointer names so that the opening and closing brace are aligned for each member line?


texts:
I currently have the following settings for hippie-expand in my .emacs file:

(setq hippie-expand-try-functions-list
  '(try-expand-dabbrev
    try-expand-dabbrev-all-buffers
    try-expand-dabbrev-from-kill
    try-complete-file-name-partially
    try-complete-file-name
    try-expand-all-abbrevs
    try-expand-list
    try-expand-line
    try-complete-lisp-symbol-partially
    try-complete-lisp-symbol))

However, there is one thing annoying me: The order of suggestions I get when I use the completion function. I want it to suggest the shortest completion first, not the longest one. For example when I write a text and I know I used the word I am currently writing and other variations before in the text, I want it to suggest the "lowest common denominator" of those words and not the longest of the words. Then I can simply type the next letter "giving emacs another hint" and use completion again. This can go on until I got the complete word. I like this more than switching through a long list of words. For code it is similar. I don't want the first suggestion to be the longest expression, which it can find in the buffers, but the shortest one, because the longest one might confuse, because it might be several lines long (for example s-expressions in any Lisp).

How can I reverse the order of suggestions or make it show the shortest first?

Edit

I now think it always suggests the least recently used completion. In text this seems OK, although I am used to having the shortest one first. However in Code, for example for some s-expressions, this is terrible, as it will insert whole blocks of code, when I only want it to complete some name of a procedure or a variable name.


texts: Does icicles works with emacs28? Debugger entered--Lisp error: (wrong-number-of-arguments (3 . 3) 2)

texts:
I am using GNU Emacs 28.0.50 and trying to enable icicles within. The error I am having:
For:
(add-to-list 'load-path "~/.emacs.d/lisp/icicles")
(require 'icicles)

error:
Debugger entered--Lisp error: (wrong-number-of-arguments (3 . 3) 2)
  make-obsolete(icicle-scatter icicle-scatter-re)
  eval-buffer(#<buffer  *load*-323141> nil "/home/alper/.emacs.d/lisp/icicles/icicles-fn.el" nil t)  ; Reading at buffer position 247290
  load-with-code-conversion("/home/alper/.emacs.d/lisp/icicles/icicles-fn.el" "/home/alper/.emacs.d/lisp/icicles/icicles-fn.el" nil t)
  require(icicles-fn)
  eval-buffer(#<buffer  *load*-374269> nil "/home/alper/.emacs.d/lisp/icicles/icicles.el" nil t)  ; Reading at buffer position 84578
  load-with-code-conversion("/home/alper/.emacs.d/lisp/icicles/icicles.el" "/home/alper/.emacs.d/lisp/icicles/icicles.el" nil t)
  require(icicles)
  eval-buffer(#<buffer  *load*> nil "/home/alper/.emacs" nil t)  ; Reading at buffer position 86650
  load-with-code-conversion("/home/alper/.emacs" "/home/alper/.emacs" t t)
  load("~/.emacs" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x14c922c058d04726>) #f(compiled-function () #<bytecode -0x1f3c692ddc0f4d75>) t)
  command-line()
  normal-top-level()

[Q] What may be the reason for this error and how can I fix it?


texts: What flows are usable with WSL and Emacs (Windows Subsystem For Linux)?

texts:
I have negative experience with Cygwin but it's only the one option I have on Windows.

In recent days Cygwin provides W32 build which has native UI (copy/paste, widgets) with tight integration to Cygwin (pty and Cygwin paths).

But BLODA ruins that workflow. Cygwin Emacs W32 constantly hangs of forks and I manually cleanup processes with procexp.

So I stick to native Emacs with cygwin-mount.el. Main disadvantage is that it lacks PTY support.

With opening of Windows Subsystem For Linux I wondered if it possible to switch Emacs from Cygwin to WSL?

Should I use native Emacs with patched cygwin-mount.el, or console WSL Emacs or X11 WSL Emacs via Xming?

WSL provides much more packages then Cygwin without fork and performance issues.

Free Ubuntu in Windows store
Free Open Suse in Windows store


texts: custom agenda view in org mode grouping per month

texts:
Using org mode agenda I've been able to customize a view to have all tasks no matter if finished or not this way:

 (setq org-agenda-custom-commands
      '(("w" "Whole Agenda no matter status"
         ((todo "TODO|IN-PROGRESS|DONE|CANCELLED")))
        ))

I need a step more: group by month showing a header, but I'm stuck. I don´t know how to group tasks by month in my custom view (preferably month of DONE date if exists, if not, then date of insertion).

something like this:

January
-------------
Project A:DONE task1  2019-01-01
Project A:CANCELLED task2  2019-01-02
Project B:DONE task3 2019-01-03
February
--------------
Project A:TODO task4 2019-02-01
Project B:TODO task5 2019-02-04

Thanks in advance


texts:
I would like to see all the lines from the current buffer, that contain some phrase, or match regex.
Example:

My buffer:

dam madam
madam

this is da
m a
dam 1
dam 2
dam pi
dam 321:)
is dam 2?

Looking for dam. Result:

dam madam
dam 1
dam 2
dam pi
dam 321:)
is dam 2?

The same buffer. Looking for regexp: ^dam\s\d. Result:

dam 1
dam 2
dam 321:)

How can I do this?


texts: Can I move imports to top of file from yasnippet using elisp code?

texts:
I want to add import statements in my yasnippets that go the top of the file (where they will be automatically sorted (or removed if the import already exists)).

from subprocess import call # I want this line moved to the top of the
                            # buffer after snippet expansion

subprocess.call("$0", ${1:shell=True})

I want the import statements moved to the top of the file because if the snippet is expanded within a code block, the import statement ends up within the block, and isort won't be able to sort the import.

Is there any way I can move the import to the top of the file using an elisp snippet within a yasnippet snippet? If so, how do I do it?

(All the elisp yasnippet examples I could find dealt with modifying inserted text, not moving stuff within the buffer after the snippet was expanded...)


texts: Org-capture menu, how I go back after selecting a template group?

texts:
When defining template groups like so:

(add-to-list 'org-capture-templates      '("a" "Group A"))
(add-to-list 'org-capture-templates      '("aa" "Group A, Sub-group A"))
(add-to-list 'org-capture-templates      '("aaa" "Group A, Sub-group A, Option A"))
(add-to-list 'org-capture-templates      '("aab" "Group A, Sub-group A, Option B"))
(add-to-list 'org-capture-templates      '("ab" "Group A, Sub-group B"))
(add-to-list 'org-capture-templates      '("b" "Group B"))
...

If I type the sequence a and a to get inside the options of sub-group A, is there a shortcut to go back one step, in this case, to the list of subgroups for Group A?

All I see is an abort option that forces me to restart the capture.


texts:
I am a bit confused on some aspects of Emacs regexps. Specifically with the
paragraph on this page

  ‘\W’ matches a character which is not within a word
  ‘\B’ matches characters which are not a word boundary
  ‘\`’ matches the beginning of the whole input
  ‘\'’ matches the end of the whole input

Can someone give examples of where each of these might apply?

Also suppose for a generic regexp R, if I augment it as ^R$ what does that mean? Does it mean it matches the expression at the beginning and end of sentences. Elsewhere on this site I have seen the regexp ^\s-$ being used to detect blank lines.

I understand each of ^ and $ in isolation but not when used together


texts: How to make `helm-projectile-grep` do a recursive search?

texts: I use helm with projectile and treemacs, how do I make helm-projectile-grep command to search in all project folders recursively starting at the project root. According to this page helm-projectile helm-projectile-grep should do it, but it does not. I've tested it and it only does grep in project root folder, or if you are in a file buffer that is deeply nested in folders it only does grep on the folder that the file is in. Any ideas? I specifically want to use helm and projectile with treemacs.


texts: How to use authinfo credentials with Magit to push/pull to Overleaf

texts:
Overleaf allows git for some users. I have been using emacs and magit with overleaf since some time by providing username-password at each git push or git pull.
What I want
Now I want to configure magit to use username and password from my .authinfo file so that it does not ask me credentials at each push or pull.
What I have

Overleaf does not allow ssh public key based authentication right now.
Using GNU Emacs 27.1 with Magit 20201218.1819.
authinfo entry

machine git.overleaf.com port 443 login email@example.com password eX@mp1e
I have also tried machine https://git.overleaf.com login email@example.com password eX@mp1e

magit config

(use-package magit
  :init
    (setq auth-source-debug 'trivia)
  :config
    (add-hook 'magit-process-find-password-functions 'magit-process-password-auth-source))

What I get
When I try to do a git push, it asks for my username. After I type in my email address (which is my username), it returns this message:
auth-source-search: found 1 results (max 1) matching (:max 1 :host "git.overleaf.com" :user "email@example.com")

And the committed changes get pushed successfully. So I guess this is a minor success since magit is able to lookup the password from the authinfo file when I provide the username.


texts: How to make evil paragraph movements work in org mode?

texts:
I'm using evil with this sample org file:

* test0
  test1
  test2

  test3
* test4

    |test5
* test6

When the cursor is on line "test6" and I press { (evil-backward-paragraph), Emacs places the cursor between lines "test2" and "test3". Then, when I press } (evil-forward-paragraph), the cursor goes to "test4".  That's not how it works in Vim.

How do I make next/prev paragraph keys place the cursor on the first empty line below/above current cursor position, like in Vim?


texts:
The smartparens-mode doesn't suit my style of editing.  If I attempt to disable it globally in spacemacs, however, the mode is re-enabled:

(smartparens-global-mode -1)

How do I disable smartparens-mode?


texts: Quickly switch to an existing task using an org-mode (similar to org-capture)

texts:
I use org-mode to keep track of time on tasks and also use org-capture to switch to new tasks that interrupt my current task. Is it possible to do something similar, to switch to an already existing task that I have in my org file? In other words, I would like to quickly switch to a task which I already have in an org-file, and once I have finished it, it should automatically take me back to the task which I was on before the switch.

Right now I go through a manual clock in/clock out to switch tasks 2 different times. Using a functionality similar to org-capture would allow me to just clock in to my new task and a clock out should automatically clock in to my previously running task. Google and stackoverflow searches did not point to a solution for this exact scenario.


texts: How to debug lsp-mode "lsp-request: method not found"?

texts:
I've setup lsp-mode and clangd, and put the compile-commands.json in the projects root.

I can tell compile-commands.json because my cflags are included in the Updating file output of *clangd::stderr* log.

However, whenever I run lsp-find-definition it simply prints:lsp-request: method not found

... unless the function happens to be defined in the same file.

How to troubleshoot this? it makes lsp-mode quite useless.

Checking the logs gives no hints as to why it fails to find the method.

For reference this is the output of lsp-describe-session:

[-] /src/blender/
 `-[-] clangd:22663
    |-[-] Buffers
    |  |-[+] BKE_blender.h
    |  `-[+] creator.c
    `-[-] Capabilities
       |-[X] workspaceSymbolProvider: t
       |-[X] textDocumentSync: 2
       |-[-] signatureHelpProvider:
       |  `-[X] triggerCharacters: [( ,]
       |-[X] renameProvider: t
       |-[X] referencesProvider: t
       |-[X] hoverProvider: t
       |-[-] executeCommandProvider:
       |  `-[X] commands: [clangd.applyFix]
       |-[X] documentSymbolProvider: t
       |-[X] documentRangeFormattingProvider: t
       |-[-] documentOnTypeFormattingProvider:
       |  |-[X] moreTriggerCharacter: []
       |  `-[X] firstTriggerCharacter: }
       |-[X] documentHighlightProvider: t
       |-[X] documentFormattingProvider: t
       |-[X] definitionProvider: t
       |-[-] completionProvider:
       |  |-[X] triggerCharacters: [. > :]
       |  `-[X] resolveProvider: nil
       `-[X] codeActionProvider: t


texts: How to make fill-region/paragraph identify a paragraph prefix?

texts:
Let's say I have the following buffer.

1. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Hitting M-q here while in text-mode leads to the following.

1. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum

On the other hand, if I activate markdown-mode, I get the following
(Markdown is just an example, you see similar behavior in various modes).

1. lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
   ipsum lorem ipsum lorem ipsum lorem ipsum

How do I configure text-mode to do that?

I imagine this can be achieved by writting a special fill-paragraph-function, but this variable is just set to nil in markdown-mode, so there's probably an easier way.


texts: Develop headline to show supplementary information

texts:
How can I easy make a function that display information in headline of buffer?

I mean that first line of buffer wouldn't be used for displaying file content and instead would be used for showing necessary information.

Like in info mode.


texts:
When typing docstring in python-mode, I always have issue with indentation. If I am at this point (| is the cursor):

def fn():
   """
   Args:|"""

If I press Enter, the cursor will move right below the A, and if I press TAB, the cursor will circle between the beginning of the line and right below A, while I want it indented:

def fn():
   """
   Args:
       |"""

Currently, I am just pressing SPACE 4-times (I am using 4-spaces indent) after pressing ENTER, but I would like to know if there is a shortcut in emacs to forcefully insert an indentation (4 spaces) regardless of the mode?

I found out that M-RIGHT inserts 4 spaces but when at the beginning of the line, it inserts 4 spaces without moving the cursor, which is pretty annoying.


texts: Showing a Custom Sum in Org-Mode's Agenda View

texts:
1 Context

In a custom org-mode agenda view (in column mode), there is a column with label μ that shows "utility ranges" in brackets. Here is what it looks like (alongside the Category and TODO columns):

|Category |   TODO   | μ             |
|cat1     | COMPLETE | [0.1μ, 3 μ]   |
|cat2     | STARTED  | [0.2μ, 4 μ]   |
|cat2     | COMPLETE | [0.2 μ]       |
|cat2     | TODO     | [0.1μ, 3 μ]   |
|cat3     | COMPLETE | [0.2μ, 6 μ]   |

Here [0.2 μ] is just short-hand for [0.2 μ, 0.2 μ].

2 Problem

What I'd like is some conditional summation data which shows -- for each category -- the sum of the utility ranges for tasks which are in the DONE state (i.e., the sum of the lowest utilities and the highest utilities in enclosed in brackets). In this case it should show something like the following:

|Category |   TODO   | μ             |
|cat1     | COMPLETE | [0.1μ, 3 μ]   |
|cat2     | STARTED  | [0.2μ, 4 μ]   |
|cat2     | COMPLETE | [0.2 μ]       |
|cat2     | COMPLETE | [0.2 μ, 0.4μ] |
|cat2     | TODO     | [0.1μ, 3 μ]   |
|cat3     | STARTED  | [0.2μ, 6 μ]   |
cat1 μ: [0.1μ, 3 μ]
cat2 μ: [0.4 μ, 0.8 μ]
cat3 μ: [0.0 μ, 0.0 μ]

3 First Attempt

I have the following function which sums μ-ranges (or any other range enclosed in brackets):

(defun bracket-sum (begin end char)
  (interactive "r\nM String: ")
  (save-restriction
    (save-excursion
      (narrow-to-region begin end)
      (goto-char (point-min))
      (let ((suml 0)
            (sumr 0)
            (regexpl (concat "\\[ *\\([-0-9.]+\\) *" char " *,"))
            (regexpr (concat ", *\\([-0-9.]+\\) *" char "*\\]"))
            (regexpm (concat "\\[ *\\([-0-9.]+\\) *" char "*\\]"))
            )
        (while (re-search-forward regexpl nil t)
          (setq suml (+ suml (string-to-number (match-string 1)))))
        (goto-char (point-min))
        (while (re-search-forward regexpr nil t)
          (setq sumr (+ sumr (string-to-number (match-string 1)))))
        (goto-char (point-min))
        (while (re-search-forward regexpm nil t)
          (setq suml (+ suml (string-to-number (match-string 1))))
          (setq sumr (+ sumr (string-to-number (match-string 1)))))
        (message "[%s%s, %s%s]" suml char sumr char)
        ))))

It can be called by enclosing a text region with bracket expressions and calling i.e. (bracket-sum begin end "μ"). So for example the sum of

[0.1μ, 0.2 μ]
[0.1μ]
[0.1μ, 0.2 μ]

is [0.3μ, 0.5 μ].

From here I'm not sure how to work this into the agenda view information. Does anybody have any thoughts on how to do this?


texts: Open recent files buffer (recentf-mode) filled with autoload.el files

texts:
I've a problem with recentf-mode buffer in emacs. Apart from the files I opened before, its also showing all the autoload files for various packages I've installed which is cluttering the Open recent buffer with unnecessary items. Like so :-

How can I stop emacs from doing this?


texts: Render align environments with MathJax for 'org-html-export-to-html'

texts:
I'm writing a document that I would like to export to LaTeX and HTML. To write my formulas I mostly use the align environment of TeX.

In the .org file I write the formulas like this:

#+begin_align
   a &= b + x \\
   d &= a - b \\
#+end_align

The export to LaTeX works as expected and I get the correct align environment. But for the HTML export begin_align and end_align are ignored and the ASCII text is displayed instead of a formula rendered with MathJax. The same happens if I use \begin{align} and \end{align} instead.

Standalone formulas work out of box.

How should/can I change the HTML export function to correctly display align environments with MathJax?


texts: Indentation of multi-line arrays within braces?

texts:
Currently in C mode, contents of a muli-line arrays are aligned with the brace. eg:

const unsigned int array[4] = {
                               A,
                               B,
                               C,
};

Is there a way to configure cc-mode to use a single indentation in this case?

const unsigned int array[4] = {
    A,
    B,
    C,
};

e.g. if indentation is set to 4 spaces.


texts: Add custom agenda options instead of replacing the whole set

texts:
I use some custom agendas for work and some for personal stuff. At the moment I load a huge set of custom agendas in org-agenda-custom-commands containing all agendas for work and for personal stuff. This clutters up the dispatcher.
When I define two different sets of custom agendas, one for work and one for personal, I can only load and access agendas of one set. But with home office, sometimes I need "work agendas" on my personal computer.
How can I write the configuration, that I can "add" sets of agendas to org-agenda-custom-commands if necessary, without completely replacing it with one set or the other?


texts: No `emacsclient` binary when building from source

texts:
I have built Emacs from source and, after make ends successfully, no emacsclient binary is present in the output (./src) directory. What is the recommended way to get the emacsclient binary in this situation to have it work with the built version?

EDIT:

Info: Ubuntu 16.04, building Emacs 26.3, build settings: ./configure --with-modules CC=clang (to avoid existing dynamic modules bug with gcc).


texts: Can I apply a face to an optional group?

texts:
When I try to execute the following, font-lock fails abruptly after it matches the first group.  A little bit of debugging with the neat tool font-lock-studio and I realized that font-lock is upset that it can't find group 2.  How can I tell it not to freak out?

(define-derived-mode expl3-mode prog-mode
  "expl3"
  "Mode for editing expl3 source code."

  (setq font-lock-set-defaults nil)
  (font-lock-set-defaults)
  (font-lock-add-keywords
   nil
   `((,(rx (* whitespace)
           (group (+ (any alnum "-")))
           (* whitespace)
           (optional "/" (* whitespace)
                     (group (+ (any alnum "_"))))      ; note
           (+ whitespace)
           (group "." (+ (any alpha)) (optional "_"))
           (group (optional (any alpha) (+ (any alpha "_"))))
           (group ":" (* (any "nNpTFwcVvxofD"))))
      (1 font-lock-variable-name-face t)
      (2 font-lock-variable-name-face t)               ; the optional group
      (3 font-lock-type-face t)
      (4 font-lock-function-name-face t)
      (5 font-lock-keyword-face t)))))

Test string

test-key .tl_set:N ...
with / grouping .code:n ...


texts: dig.el broken when invoking with type? How to fix?

texts:
Running emacs 26.1 on window using bind tools x64 9.13.

When I M-x dig heise.de MX it seems the question gets mangled:

; <<>> DiG 9.13.0 <<>> heise.de MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 33985
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;heise.de\032MX.            IN  A

;; AUTHORITY SECTION:
.           2748    IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2018061001 1800 900 604800 86400

;; Query time: 80 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Sun Jun 10 21:35:46 ope 2018
;; MSG SIZE  rcvd: 115

But when I cmd.exe dig heise.de MX I get the correct output:

; <<>> DiG 9.13.0 <<>> heise.de MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34942
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;heise.de.                      IN      MX

;; ANSWER SECTION:
heise.de.               86400   IN      MX      10 relay.heise.de.

;; Query time: 62 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Sun Jun 10 22:36:13 W. Europe Daylight Time 2018
;; MSG SIZE  rcvd: 59

How do I fix this? Or is it just an input syntax error on my side? I tried multiple variants but I always end up with this "\032" in emacs.


texts:
Is it considered better to use TRAMP to access remote files on a local copy of Emacs, or to ssh into the remote server and access the files using a remote copy of Emacs in the ssh session?

What are some of the considerations involved in making this decision?


texts: Identify which mode is throwing an error

texts: I am attempting to edit a file. Emacs is preventing me from making the edit, and throwing: Args out of range: #<buffer user.action.js>, 4965, 17721. It is completely not obvious to me where this exception is coming from. How can I debug errors such as this one?


texts: Flycheck c/c++-clang check linux kernel headers

texts:
Currently I am working with the linux kernel, but I am struggling trying to check my syntax using flycheck, I already added the path of the headers in the clang-path but it is not enough. Does any of you know how to properly analyze the files?

  This is the command run to check the syntax:

   clang -fsyntax-only -fno-color-diagnostics -fno-caret-diagnostics -fno-diagnostics-show-option -iquote /root/Projects/OS-Project/ -Wall -Wextra -I /lib/modules/4.11.3-1-ARCH/build/include -x c - < /root/Projects/OS-Project/main.c

This is an image showing where the compiler fails:

Only tags are helping me right now.


texts: The default value of buffer-local variable not set until first `setq`

texts:
Say I define a buffer-local variable foo, and its default value is "a":

(defvar foo "a")
(make-variable-buffer-local 'foo)
(default-value 'foo) ;; => "a"

Immediately after this I run the following code:

(let ((foo "b"))
  (with-temp-buffer
    (message "foo: %s" foo))) ;; => "b"

The result is "b", which is the value I set in let.

Now if I use setq to set the variable, then rerun the exact same code as before:

(setq foo "c") ;; => "c"

(let ((foo "b"))
  (with-temp-buffer
    (message "foo: %s" foo))) ;; => "a"

The result is "a", which is the default value now.

The question: for a temporary buffer, the default value of foo is not set until I use setq? And as long as I don't use setq, I can use let to change the default value in other buffers?

EDIT: as @npostavs said, this is what make-varible-buffer-local really means. If I use make-variable-buffer-local myself, I can always use setq after that. But this becomes really tricky for the "built-in" buffer-local variables like case-fold-search. if I, as a package author, bind case-fold-search to nil in the outer let, and I want to use the default value (it might or might not be set by the user) in the with-temp-buffer, I have to use setq before with-temp-buffer to make sure the default value is actually being used in case the user doesn't have that setq in his/her init.el. For buffer-local variables, it probably means setq is always safer than let when we want to set the value. I wonder whether the design or the documentation could be improved.


texts:
I would like to programmatically call an ivy or counsel function and then immediately execute ivy-occur to get the ivy-occur buffer.

Example:
Instead of doing M-x counsel-describe-function and C-c C-o manually to get the ivy-occur buffer I would to do this with a function.

Tried the following (the last three solution work but there has to be a better way):

Minibuffer-setup-hook

Works for some (counsel-M-x) but most commands give me an ivy-occur buffer with 0 candidates. So this is probably called too early:

(unwind-protect
    (progn
      (add-hook 'minibuffer-setup-hook #'ivy-occur)
      (ignore-errors (counsel-faces)))
  (remove-hook 'minibuffer-setup-hook #'ivy-occur))

Minibuffer-with-setup-hook

Same problem as with the hook.

(ignore-errors
  (minibuffer-with-setup-hook
    (:append #'ivy-occur)
  (counsel-faces)))

Execute-kbd-macro

This actually works, but there has to be a better way to do this. This just simulates the keys pressed:

(execute-kbd-macro (kbd "M-x counsel-faces RET C-c C-o"))

;; Can even change the initial input like this (`ivy-`).
(execute-kbd-macro (kbd "M-x counsel-faces RET ivy- C-c C-o"))

Run-with-idle-timer

This works as well but is sort of strange too. Not even sure if this might be run before calling counsel-faces in some cases.

(progn
  (run-with-idle-timer 0.01 nil #'ivy-occur)
  (counsel-faces))

Unread-command-events

Found this in the question Clean way to perform commands in the Emacs minibuffer. But this also feels akward.

(progn
  (setq unread-command-events
      (append (listify-key-sequence (kbd "C-c C-o")) unread-command-events))
  (counsel-faces))

Thanks for any solution or a hint on how to do this properly.


texts: how to do command substitution in eshell generally (NOT just for loop)

texts:
How to do command substitution à la Bash in Eshell, and not just for loops? (Unfortunately, while this question asks my question, its answer only provides Eshell for-loop syntax. So please don't dupe me with that: I seek an answer to the general question, using the example below.) FWIW,

I'm a longtime Basher trying to learn Eshell. I like to think I'm Bash-strong (at least, I've been using it forever both at commandline and for scripts) but ...
... I know I'm Elisp-weak. I've adapted or written a few functions for my init.el and do some C-u M-: in buffers, but that's about it.
I'm running Emacs on a Linux.

For this usecase, I want to look at all the *Office docs in a particular filetree

sorted by time (required)
in a Dired buffer (preferred)

Let the filetree root=~/foo/bar/. I can satisfy condition 2 with find-name-dired, but not condition 1: when I do

M-x find-name-dired ~/foo/bar/ *.odt

and then press s in the resulting buffer, I get the error

Cannot sort this Dired buffer

So I think, "I know how to do this in Bash. Perhaps if I do it in Eshell, that will give me a Dired buffer?" So I do

M-x eshell

but get

Welcome to the Emacs shell

~/foo/bar $ ls -alt $(find . -name '*.odt')
Invalid read syntax: ". in wrong context"

I assume that's a Lispism, and instead try

~/foo/bar $ ls -alt $(find ./ -name '*.odt')
Invalid read syntax: ")"

I've tried escaping the {parentheses, round brackets} various ways, and even backticks (note to reader--don't use backticks :-) to no avail: I either get the Invalid read syntax: ")" or more catastrophic errors. I then tried various sorts of C-h and websearch, without success. What am I doing wrong, and how to fix?


texts: Requiring user-installed packages from byte-compiled .emacs

texts:
I have the following in my .emacs.el:

(when (require 'edit-server nil t)
  (custom-set-variables
   '(edit-server-default-major-mode 'markdown-mode)
   '(edit-server-new-frame nil))
  (edit-server-start))

The file is byte compiled, so what is actually loaded is .emacs.elc.

edit-server is installed using the package system (package-list-packages).

When I start Emacs,

edit-server is not running
(featurep 'edit-server) is nil
the variables are not set.

When I open .emacs.el and evaluate the when form, the server is started.

When I load .emacs.elc from dired right after starting emacs, the server is started.

When I start emacs -q, no matter how many times I load .emacs.elc, the server is not started.

So, why can't I start the server this way?


texts: Projectile has a function to close all buffers related to a project (projectile-kill-buffers). Normally I also open non project related files during the day or emacs opens them when I'm stepping through compiler errors. Is there a way to close all buffers except project and special buffers?