texts: How to (correctly) hex encode a URL so that it becomes a valid address I can paste into my web browser?

texts:
Here is a valid URL which loads the intended page when I paste it into my browser:

https://en.wikipedia.org/wiki/Blue_(disambiguation)

For reasons I will explain later, I want to hex encode the last segment so it will look like this:

https://en.wikipedia.org/wiki/Blue_%28disambiguation%29

This doesn't change the URL:

(url-encode-url
 "https://en.wikipedia.org/wiki/Blue_(disambiguation)")
;; => "https://en.wikipedia.org/wiki/Blue_(disambiguation)"

This breaks the URL, making it unacceptable to the web browser:

(url-hexify-string
 "https://en.wikipedia.org/wiki/Blue_(disambiguation)")
;; => "https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FBlue_%28disambiguation%29"

The reason I want the URL encoded this way is because markdown links get broken if the URL contains parens. When I write an Org document containing a link to the URL and then export it to markdown by C-c C-e m M it produces this:

[wikipedia](https://en.wikipedia.org/wiki/Blue_(disambiguation))

When the markdown is rendered to HTML (server side) it produces a link to https://en.wikipedia.org/wiki/Blue_(disambiguation (missing the closing parenthesis) followed by a ) (plain text closing parenthesis) which is not part of the link address:

blue)

I can't change the markdown processing server side, and I don't know enough about org-export to say whether this is a legitimate bug or intended behavior. I only know that it is not the behavior I desire, and I have to work around the problem somehow.

I have found that I can repair the link by expressing the parentheses in percent encoded form. So I want to transform the broken markdown produced by org-export to look as follows:

[wikipedia](https://en.wikipedia.org/wiki/Blue_%28disambiguation%29)

The following is as close as I have come, but it is very inconvenient to use and seems like it would be quite fragile in face of unanticipated inputs:

;; (correctly-hex-encode-wikipedia-url
;;  "https://en.wikipedia.org/wiki/Blue_(disambiguation)")
;; => "https://en.wikipedia.org/wiki/Blue_%28disambiguation%29"
;;
(defun correctly-hex-encode-wikipedia-url (url)
  "Fix last segment of URL so it doesn't break markdown.
Wikipedia urls contain parens in the last segment which break
markdown links. This replaces them with percent encoded (aka
hexified) characters. It may do other unwanted things depending
on what you give it. This is just my way of getting around the
broken markdown exported from Org mode."
  (concat
   (substring url 0
      (string-match "[^/]+$" url))
   (url-hexify-string (substring url
                                 (string-match "[^/]+$" url)
                                 (length url)))))

(defun replace-region-with-correctly-hex-encoded-wikipedia-url ()
  "Changes the url in region."
  (interactive)
  (insert
   (correctly-hex-encode-wikipedia-url
    (delete-and-extract-region (point) (mark)))))

Edit to incorporate browse-url-url-encode-chars

(defun replace-region-with-correctly-hex-encoded-wikipedia-url ()
  "Replaces text in region with percent encoded parens."
  (interactive)
  (insert
   (browse-url-url-encode-chars
    (delete-and-extract-region (point) (mark))
    "[()]")))


texts: Access and adjust global variable from org-mode as local buffer variable

texts:
I'm currently working with a lot of javascript in my org files.

Therefore I introduce a local buffer variable that will automatically insert javascript as language identifier in my file whenever I use <s TAB.

Here is how I've done it, it's inspired by the mailing list post here.

# -*- org-structure-template-alist: (("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC")); -*-

When I put this as first line in my org file it will complete <s to the desired.

#+BEGIN_SRC javascript

#+END_SRC

Now when I look up the definition C-h v org-structure-template-alist the current value is just.

Value:

(("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC"))

While the original value was:

(("s" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")
 ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE" "<example>\n?\n</example>")
 ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE" "<quote>\n?\n</quote>")
 ...

So is it possible to access the global definition of org-structure-template-alist inside the local org defining block and just replace the default binding to <s with my definition?

This way I can use <s to get the javascript, but also use the other defined shortcuts like <e for Example block. Currently the buffer in which I define org-structure-template-alist will only complete <s and ignore all things.

I tried this but it doesn't seem to evaluate the add-to-list.

# -*- org-structure-template-alist: (add-to-list 'org-structure-template-alist (("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC" "<src lang=\"javascript\">\n\n</src>"))); -*-

Update:

This is now my final solution based on the answer of Tyler. I include the following code as last statement in my org file. It is marked as a comment so it won't get exported, which was also a requirement. Loading the file now ask if I want to apply local variables, but this is not a problem right now.

* COMMENT
### Local Variables:
### eval: (make-variable-buffer-local 'org-structure-template-alist)
### eval: (add-to-list 'org-structure-template-alist '("s" "#+BEGIN_SRC javascript :tangle yes\n?\n#+END_SRC" "<src lang=\"javascript\">\n\n</src>"))
### End:


texts: Fullscreen one out of two monitors in EXWM

texts:
When I am running Chromium in EXWM I can fullscreen YouTube across two monitors using YouTube's fullscreen button or F, and I can fullscreen Chromium itself across two monitors with Emacs's C-c C-f which runs exwm-layout-set-fullscreen.

Naturally there isn't much point in watching a YouTube video on one half each of two monitors. How can I tell EXWM to fullscreen something across one monitor only?

Note that the problem exists in tiling mode as well as floating mode.


texts: How to know if the buffer returned by a function is newly opened?

texts:
I'm using a command that reverts a diff chunk in a buffer (linked question), however I don't know if the buffer is newly opened - or if an existing buffer is used.

While I could make a list of all buffers, then check if that buffer is in the original list, is there a better way to know if the buffer from a function is newly created or not?


texts: Can not restore solarized dark theme after updating all packages via MELPA

texts:
I updated all my packages via MELPA today and I previously had a solarized dark theme and now its solarized light. I did not change my init.el or any settings. Emacs is not showing any errors. Wondering what the issue likely is and how can I restore the theme?

I have posted this as an issue on : https://github.com/bbatsov/solarized-emacs/issues/167


texts: I would like to maintain a list of acronyms in my org-mode file. Should I just use Description plain lists for that or is there a better way?


texts:
What determines the shape of the result of a vector mapping (V M)?  I had thought it was directly based on the shape of the input, but have a look at this.

k f factors an integer, returning a vector of its prime factors.  Given a vector of n integers,

[27 31 33]

V M k f will factor all of them, yielding

[[3, 3, 3], [31], [3, 11]]

which is what I'd expect.  But if all of them are primes, for example

[31, 37, 41]

then the output of V M k f is

[ [ 31 ]
  [ 37 ]
  [ 41 ] ]

The shape (H v l) of the first result is [3]; the shape of the second result is [3, 1].  Why?


texts: How to get align-regexp to help line up Markdown tables properly?

texts:
I am trying to line up a text table using align-regexp. A table, before alignment, looks like this:

| Alpha | Bravo | Charlie |
|-------|-------|---------|
| Delta | Echo | Foxtrot |
| Golf | Hotel | India |

and after alignment should look like this:

| Alpha | Bravo | Charlie |
|-------|-------|---------|
| Delta | Echo  | Foxtrot |
| Golf  | Hotel | India   |

The best result I've gotten is C-u M-x align-regexp, then \(\s-*\)| as regexp, then repeat throughout line. What I get is this:

                        | Alpha  | Bravo  | Charlie  |
                        |------- |------- |--------- |
                        | Delta  | Echo   | Foxtrot  |
                        | Golf   | Hotel  | India    |

The pipes line up, but now it's indented some random number of spaces that seems to be dependent on the content of the table. The problem with this is that markdown, the format of the document, now treats it as code because its indented.

My quick, but tedious, fix is to un-indent it, but I'd like to find out the right incantation for align-regexp to make this indentation work properly.


texts: How can I run a package setup only once?

texts:
I'm writing a package to interact with a web service via HTTP API. But I need to make an action once to get permission to send my data. This action must be made just one time.
How can I configure my package to run this setup function only once after installed?


texts: Why does modification in another buffer create undo boundary in current buffer?

texts:
I just noticed that modifying another buffer creates an undo barrier in the current.

For example:

(defun my-test-undo ()
  (interactive)
  (insert "A")
  (with-current-buffer (get-buffer-create "FOO")
    (insert "abc"))
  (insert "B"))

The command will print AB. When hitting undo, only the B is removed. A second undo is needed to remove the A.

This version logs buffer-undo-list:

(defvar my-test-undo-log nil)
(defun my-test-undo-with-log ()
  (interactive)
  (setq buffer-undo-list '())
  (let ((before buffer-undo-list))
    (insert "A")
    (with-current-buffer (get-buffer-create "FOO")
      (insert "abc"))
    (let ((mid buffer-undo-list))
      (insert "B")
      (setq my-test-undo-log (list before mid buffer-undo-list)))))

After running this my-test-undo-log contains three versions of the undo information. In the last a nil has been inserted, indicating an undo barrier.

I came up with the following to manually modifying the undo list, but it feels like a hack. (Of course, it can be slimlined into a macro.)

(defun my-delete-nil-until (list sublist)
  ;; Strip of leading nil:s
  (while (and (not (eq list sublist))
          (null (car list)))
    (setq list (cdr list)))
  ;; Destructively remove nil:s
  (let ((next list))
    (while (not (eq (cdr next) sublist))
      (if (car (cdr next))
      (setq next (cdr next))
    (setcdr next (cdr (cdr next))))))
  list)

(defun my-test-undo-with-workaround ()
  (interactive)
  (let ((before buffer-undo-list))
    (insert "A")
    (with-current-buffer (get-buffer-create "FOO")
      (insert "abc"))
    (insert "B")
    (setq buffer-undo-list (my-delete-nil-until buffer-undo-list before))))

Is there any rational reasons why Emacs should behave this way, or is it a bug?

Are there better ways to handle this, like a built-in macro I've missed?


texts: Are keybindings mode-dependent? How can I customize this?

texts:
I have bound the eval-region function to H-x

I would like to use this to simply highlight selected code and evaluate - simple.

Working in a Python script I have the following code:

def test(this, that):
    output = this * that
    return output

print test(2,4)

When I highlight it and press H-x, I get the error message: "Symbols' value as variable is void: def"

Still having the same code highlighted, in the Python dropdown in the menu bar I click on "eval region" and I get the expected output (i.e. 8).

I have seen an explanation of void variables, but I don't really understand it all - I just want H-x to perform eval-region as clicking on the menu-bar version does.

Does anyone know a fix, work-around or the required setup?


texts: Strange Emacs Colors in gray30 Background Urxvt

texts:
Recently I've been trying out different terminal color schemes. However, I found out that when I change the background of urxvt to gray30, emacs -nw has completely different syntax coloring.

I've not found this with any other background color, and I can't find any information about why this happens. While I actually quite like these new colors, I'm very confused.

Questions:

How can I stop this behavior?
Do other people have the same experience?

Information:

Version: Emacs 26.1
Terminal: rxvt-unicode (urxvt) v9.22
OS: Void Linux

The relevant part of my .Xdefaults reads:

! Colours:
URxvt.cursorColor: lightblue
! *background: #181818
*background: gray30
*foreground: #bbbbbb

The color changes happen irrespective of my shell, urxvt's foreground and cursor colors, and the font.
The ansi-color-name-vector in my init file don't change.
No other terminal program changes it's colors, and oddly, the modeline colors don't change either, but I do have a custom mode-line config.

Thanks for any help!


texts: Why do I get free variable warnings with use-package?

texts:
I have, for instance, this in my .emacs:

(use-package company
  :bind (("M-RET" . company-complete))
  :demand                               ; load it now (better for eglot)
  :config
  (global-company-mode)
  (setq company-backends '(company-capf company-semantic company-dabbrev-code
                                        company-dabbrev company-etags
                                        company-keywords))
  (setq company-dabbrev-downcase nil ; make case-sensitive
    company-dabbrev-ignore-case nil) ; make case-sensitive
)

The last setq gives flycheck free-variable warnings for company-dabbrev-downcase and company-dabbrev-ignore-case even though they are both defined with defcustom in company-mode. Should I just ignore these warnings, or should I do something differently to fix them?


texts: What are the downsides of changing the syntax class of quotes in text-mode and backslash in AUCTeX?

texts:
It bothered me that sexp navigation commands didn't treat a quoted string as a single expression in text-mode. This is because the quote character " is in the punctuation syntax class in the text-mode syntax table. I decided to make it a string delimiter:

(modify-syntax-entry ?\" "\"" text-mode-syntax-table)

Similarly, I wanted sexp navigation commands in AUCTeX buffers to treat the initial backslash in a macro as part of the macro (as happens in the built-in latex-mode), so I changed the class of \ to expression prefix:

(modify-syntax-entry ?\\ "'" LaTeX-mode-syntax-table)

Now, I've been told that modifying syntax tables is "dangerous" and can have "far-reaching unintended consequences", but I've been using those for months and so far I haven't noticed any consequences other than improved sexp navigation.

So my question is: what can actually go wrong? A good answer would be a specific example of some text and some commands that have different outcomes with and without the syntax class change, where the outcome with the change is clearly inferior in some way. Is there any actual danger or is this just an abstract fear some people have?


texts: Binding " x" to a command (Mouse buttons as prefix or modifier keys)

texts:
On my laptop, mouse buttons are right under my thumb. I would like to use them as prefix or modifier keys. For example, holding mouse-3 and pressing x launches helm-M-x.

I tried the followings, however, the mouse-3 still acts as a right click (its default behavior).

(global-set-key (kbd "<mouse-3-x>") 'helm-M-x)

Then I tried to unbind mouse-3 first:

(global-set-key (kbd <down-mouse-3>) nil)
(global-set-key (kbd "<down-mouse-3> x") 'helm-M-x)

Now mouse-3 x just types x. Also:

(define-key c++-mode-map [down-mouse-1 x] 'helm-M-x)

Same behavior.

Is there a way to do this?


texts:
When getting an Elisp error and trying to debug the problem, the backtrace buffer is quite hard to read with its long lines.

Is there a way to get a pretty-printed backtrace buffer?


texts: Make org-mode not to insert day name in timestamps

texts:
When I insert timestamps, even if by using the calendar, org inserts something like <2016-10-20 Thu>. However, I sometimes have to use machines with a different locale, which inserts <2016-10-20 cs>.

This, of course, I can parse, but it makes my (otherwise fully English) Org files look inconsistent. Given that Org doesn't parse the day name and inserts it for pure readability reasons[citation needed], is there a way to prevent Org inserting it at all?


texts:
When I want to try some packages that need xwidgets, I found Arch linux's default Emacs has not Xwidgets support. This is not the only distribution that doesn't include Xwidgets in compiling Emacs. I saw Debian had the same issue before as well.

I compiled Emacs with Xwidgets and it works fine. Does anyone know why this feature is not turned on by default for several distributions? It seems this is due to some problem of webkitgtk before, but webkitgtk is good today. I'm curious why this great feature of Emacs is still not default. (AFAIK, it was introduce in 25.1.)


texts: How automatically load a mode with another mode (web-mode with zencoding-mode)?

texts:
I have web-mode (which is awesome, by the way).
The following line:
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
every time when a .html file is loaded, web-mode will be enabled.

But I would like when web-mode is loading in .html-files, then the zencoding-mode (a minor mode) will be also enabled by default. I tried various ways to get this worked.

For example (add-hook 'web-mode-hook 'zencoding-mode)will not work.

And (add-to-list 'auto-mode-alist '("\\.html\\'" . zencoding-mode))
gives problems. Then web-mode is not being loaded, but zencoding mode is being loaded (because that's the last line to be evaluated, so replaces web-mode when a html-file is being opened.

Any suggestions? I would be genuinely thankful.


texts: Show org todos with certain tag in designated file

texts:
I want to implement a certain time-management system in emacs/org-mode.
For each project, I intend to have one .org file which includes all associated to-dos. I already created those.
Now, I would like to have one 'this month' and one 'this week' file, which show all to-dos from the above project files which I have given a corresponding tag 'this month' and 'this week'.
The 'this week' file I want to use to document my progress on the tasks, and I want to have the to-dos as headlines which I can also interactively label as 'done' from the 'this week' file, so they get shown as completed in the 'this month' and the project file.
Is this possible in emacs/org-mode? I created the project files and gave the tags, but I don't know how to create month and week files as I intend.
I've read this related thread: SCHEDULE task for year or month but I'm more concerned with showing to-dos with certain tags in two different files. Doesn't have to be agenda.


texts: How can I send Super from my Mac to my Emacs instance?

texts:
I run emacs in two ways: One as a Mac OS X executable, built from source, and the other as a Linux executable using the Lucid toolkit, in daemon mode, connected to using a graphical emacscient using XQuartz on my mac laptop.

My base configuration is currently Emacs Prelude, and it defines a set of key chords that use a Super key, in addition to some Meta and Ctrl chords. However, I cannot figure out how to send a Super chord at all. This is true both on my OSX build and on my emacsclient/XQuartz setup. Command sends Meta, Option just sends literal keys (in the OSX way, it emits a subset of the extended Unicode space) and obviously Shift and Ctrl do their usual thing.

So, how do I send super-prefixed key chords to my Emacs?


texts:
When I do dired-do-copy on a file with a quotation for example "test"f.txt,

I get the following error when copying/moving file with quotation symbols

Copy ‘/home/user/Music/"test"f.txt’ to ‘/media/user/Audio/"test"f.txt’ failed:
(file-missing Opening output file No such file or directory /media/user/Audio/"test"f.txt)

The above behaviour is same for dired-do-rename when moving file to a directory.

Is there a way for dired to escape special characters or do I need to rename files?


texts: Disabling Magit's untracked files status

texts:
I'm trying out Magit for a monstrously large monorepo at work (think millions of lines of code) and there are many untracked build artifacts. From my shell I always use git status -uno to avoid having git try to unenumerate all of the artifacts that should be ignored but aren't.

I wish I could just add things to the .gitignore files, but sadly this is just not feasible (layer 8 problem in the networking stack...).

Can I configure magit to not interact with untracked files at all when refreshing?

I found this question, but I don't want to just hide the untracked section, but avoid the mega latency from git attempting to enumerate the thousands of untracked files (that I don't care about).


texts:
After upgrading to emacs 27

brew install emacs --HEAD

I get this on startup

    $(which emacs) --daemon
    ...
    Warning (initialization): An error occurred while loading ‘/Users/username/.emacs.d/init.el’:

    File is missing: Cannot open load file, No such file or directory, ob-scala

    To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
....


texts:
I would like to have ; bound to other-window in special modes, unless the derived mode overrides the definition. It would be nice to also include modes not strictly deriving from special-mode (but defining 'mode-class), but that's not strictly necessary.

Ideas I've tried/considered:

Use global-set-key: I thought the global keymap would be of lower precedence than major-mode keymaps, so ; would work in modes that defined it, but instead I just overwrote self-insert-command
Add the keybinding in special-mode-hook: It doesn't seem like this hook is actually run, and this misses the 'mode-class special modes
Add a keybinding that either calls other-window or defers to the major mode. Not sure how I would do this?

Any ideas?


texts:
The GNU elisp documentation states:

"Generally, you should not modify exec-path directly. Instead, ensure that your PATH environment variable is set appropriately before starting Emacs. Trying to modify exec-path independently of PATH can lead to confusing results."

Given that it is not, in general, possible to ensure the path is correctly set before launching emacs (macOS GUI v's terminal being my case of interest), is it possible to modify the PATH variable from my .emacs, and then have Emacs regerenate the exec-path variable as is done during start-up?

Edited after comment from @lawlist

Using the exec-path-from-shell I observe the following behaviour:

When starting Emacs:

$PATH = "/usr/bin:/bin:/usr/sbin:/sbin"

exec-path = "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/MacPorts/Emacs.app/Contents/MacOS/libexec" "/Applications/MacPorts/Emacs.app/Contents/MacOS/bin"

After running exec-path-from-shell-initialize:

$PATH = "/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin"

exec-path = "/opt/local/bin/" "/opt/local/sbin/" "/Library/Frameworks/Python.framework/Versions/3.7/bin/" "/usr/local/bin/" "/usr/bin/" "/bin/" "/usr/sbin/" "/sbin/" "/Library/TeX/texbin/" "/opt/X11/bin/" "/Applications/MacPorts/Emacs.app/Contents/MacOS/libexec/"

So the "/Applications/MacPorts/Emacs.app/Contents/MacOS/bin" component that is added to exec-path during Emacs start-up is removed by the exec-path-from-shell package. Is this expected? What is the rational for the package removing it from exec-path?


texts:
Emacs 25.1.
I start M-x shell. And run some process that generate text to output. How can I filter this output?


texts: How to auto-format an Elisp file on save?

texts:
Having used clang-format to format the buffer when saving, I find this functionality useful.

Are there tools to reformat an Elisp buffer when saving?


texts: Enabling compilation-shell-minor-mode in GUD (for next-error)

texts:
I want to see stack trace lines highlighted in GUD and have next-error work there.  That works for me if, after starting GUD (via M-x pdb) I enable compilation-shell-minor-mode.

However, if I do this:

(add-hook 'pdb-mode-hook (lambda () (compilation-shell-minor-mode t)))

Then when I run M-x pdb, I get that minor mode enabled, but the matching error lines in the buffer don't get highlighted.  I then have to disable and re-enable the minor mode to get the highlighting back.

How can I configure things so that the minor mode works fully as soon as I start GUD?


texts:
What is the idiomatic way to make one face the same as another?

Basically, I would like vertical-border to be exactly the same as default. Preferably, if default changes, so does vertical-border.

I'm not sure that creating a face alias is the right thing to do.

It's not clear that we should be aliasing one face as another.
By the time the init file is loaded, the vertical border has already rendered, and aliasing does not re-render the vertical border

At the very least, I'd like to have something like (copy-face 'default 'vertical-border) that copied all attributes of default into vertical-border, even if it's a one-time thing and the latter will not change when the former does.


texts: How do I get spacemacs working on machine without internet?

texts:
My idea was to set up spacemacs on a machine that has internet, then push the .spacemacs file and the .emacs.d/ directory to the machine without internet.  However, when I did this and start emacs on the machine without internet, it says "found 166 new packages to install..." and tries to reach melpa.

Well -- I'm not actually pushing the entire .emacs.d/ directory, because the .gitignore excludes several -- perhaps that's the issue?

The directories I'm currently including are: assets, core, doc, layers, news, tests.  Should I be including others?


texts: What are the practical differences between the various Emacs Package Repositories?

texts:
I notice that there are several different repositories that often contain the same software.  Why would I want to prefer:

GNU ELPA
Marmalade
MELPA

over the others?  Since any one repository does not contain all the packages that I want, is it a good idea to have these repositories enabled simultaneously?


texts: How to disable changing the current buffer by clicking buffer name in mode line?

texts:
I find myself accidentally clicking the mode line when trying to focus a buffer with the mouse.  This causes the buffer to change.  I don't want that behavior.  I want nothing to happen.

The culprit is this guy here, the part of the mode line that says the buffer's name (e.g. *shell*):

How can I disable it's behavior when it clicked?

I am told it is <down-mouse-1> by C-h k.  However, this corresponds to mouse-drag-mode-line which resizes.  This is not the behavior I observe.  I cannot locate the appropriate key to override.


texts:
Having written a function (say, my-func), I wanted to map it in ledger-mode-map to the keypress that I will call "Control dollar," that is, the dollar sign $, typed while the Ctrl key is held down.
The expression:
(define-key ledger-mode-map (kbd "C-$") 'my-func)

when executed does not indicate a failure, but a subsequent C-h my-func indicates no key binding.
Executing C-h k C-$ produces the output "C-$ is undefined".
I need a way to express "Control dollar" so that Emacs can recognize it as a keypress, if that is even possible.  Here are a few of the alternatives I have tried to (kbd "C-$"):

Expression
Result when evaluated

[?\C-4]
67108916

[?\C-\$]
67108900

(kbd "C-\$")
67108900

[C-S-4]
[C-S-4]

(kbd "[67108900]")
"[67108916]"

[$]
[$]

[\$]
[$]

(kbd "C-[$]")
C- must prefix a single character, not [$]

(kbd "C-$")
67108900

[(control $)]
[(control $)]

[(control \$)]
[(control $)]

@amitp: It does work if I use global-map instead of ledger-mode-map. It does not work if I use, say, C-! instead of C-$ with ledger-mode-map.


texts: Can't launch emacs from outside bin directory

texts:
I'm building emacs from source (the feature/native-comp branch) on Ubuntu inside WSL 2. This was working a couple weeks ago, but today it stopped (I hadn't used it in some time though).
I've cloned emacs from git://git.savannah.gnu.org/emacs.git.
I build with this:
$ ./autogen.sh
$ ./configure --prefix=$HOME/.local --with-native-compilation
$ make -j12
$ make install

I end up with the following files in the bin directory:
$ ls -lh
-rwxr-xr-x 1 gregg gregg 198K Apr 16 18:49 ctags
lrwxrwxrwx 1 gregg gregg   13 Apr 16 18:49 emacs -> emacs-28.0.50
-rwxr-xr-x 1 gregg gregg 7.2M Apr 16 18:49 emacs-28.0.50
-rwxr-xr-x 1 gregg gregg  37K Apr 16 18:49 emacsclient
-rwxr-xr-x 1 gregg gregg 194K Apr 16 18:49 etags

I know it's on the path because:
$ which emacs
/home/gregg/.local/bin/emacs

I've also manually verified that /home/gregg/.local/bin is on the PATH.
When I try to run emacs from any directory except /home/gregg/.local/bin:
$ emacs
emacs: could not resolve realpath of "emacs": No such file or directory

If I'm inside the bin directory emacs works normally calling it either relative to the current location or from the path (./emacs or emacs).


texts: How do I get comments in a noweb expansion?

texts:
Given the org-mode file

* File Description
  :PROPERTIES:
  :comments: org
  :tangle:   file.sh
  :noweb: yes
  :END:

** A function call
This is foo
#+BEGIN_SRC sh :noweb-ref myfunction :tangle no
hello_world()
#+END_SRC

** Additional info
This is bar
#+BEGIN_SRC sh :noweb yes
  hello_person()
  <<myfunction>>
#+END_SRC

When I tangle the file with C-c C-v t, my expectation would be the following result.

# Additional info
# This is bar

hello_person()

# A function call
# This is foo

hello_world()

But this isn't what happens, The comment from the myfunction noweb-ref is stripped from the final result and it looks like this.

# Additional info
# This is bar

hello_person()
hello_world()

Is there a native way to get this behaviour or do I advise org-babel-expand-noweb-references?


texts:
I have been on the agenda of actually applying the formatting done by various programs within various types of Emacs major modes, e. g., the compilation major mode. I found this and added this to my configuration file:
(use-package ansi-color
  :config
  (defun my-colorize-compilation-buffer ()
    (when (eq major-mode 'compilation-mode)
      (ansi-color-apply-on-region compilation-filter-start (point-max))))
  :hook (compilation-filter . my-colorize-compilation-buffer))

This got me most of the colours! Although every now and then I still see some uninterpreted (what looks like) escape codes. Here I show an example in compilation mode buffer *Compile-Log*,

What is this "^L" and how can I apply its effects as desired rather just printing out some representation of the actual code.


texts: forward paragraph -- ignore carriage return in comment

texts:
I like to use the forward- and back-paragraph methods to jump around my source code.  I would like it to behave slightly differently though.  Consider the following comment block:

// comment line one.
//
// comment line two.

I'd like to jump over the entire comment block, and not land in-between line and and two -- in other words, I'd like it to consider a contiguous comment block as a single paragraph.

Anyone know how to do this?


texts: Installing font package only once via command in file

texts:
I have a package that install the all-the-icons-package automatically namely

(use-package zerodark-theme
:ensure t
:init
  (load-theme 'zerodark t)
  (zerodark-setup-modeline-format))

all-the-icons state that for the correct fonts I have to invoke

  M-x all-the-icons-install-fonts

How can I put this command into a file so that it is installed only the first time after a fresh Emacs


texts: Prevent dired recenter buffer when reverting buffer

texts:
When a directory contains many files, more than the visible lines of the window, use end-of-buffer to go to end of buffer, then press g to revert-buffer, one can see the last line is recentered to the middle of the window.
How I can prevent this?


texts: Something like save-excursion that saves the complete buffer state?

texts:
[This question is related to, but not a duplicate of, the question copy contents of current buffer in a temp buffer and operate on that. Besides other incidental things (e.g., the question itself is different), none of the solutions offered both (1) execute the elisp in the same context as the original buffer, AND (2) maintain the state of the original buffer. Indeed, the purpose of the macro offered as a possible solution (with-indirect-buffer-in-foo-mode) in that question seems to be to actually edit the original text in a different mode. The macro also doesn't maintain the buffer-undo-list, of course (nor any other 'state' that may change when the text of a buffer changes).]

I'd like to be able to write

(save-complete-buffer-state
  (edit-the-buffer-arbitrarily)
  (condition-p))

and have everything (or as much as is practical) be preserved from the original emacs buffer state before the call, including, for example, point, kill ring, undo list, etc. Does such a macro already exist? If not, how difficult would it be to implement? (What needs to be saved?)

(I've found c-save-buffer-state at

Emacs: How to intelligently handle buffer-modified when setting text properties?

but I don't know enough about what needs to be done to understand how close this is to doing what I'm asking.)

EDIT: Using lawlist's and @phils' suggestions, I was able to come up with this solution. Please note that this macro works on a few simple test cases but has not been tested extensively.

(defmacro with-cloned-buffer (&rest body)
  "Executes BODY just like `progn' but maintains original buffer state."
  (declare (indent 0))
  (let ((return-value (make-symbol "return-value")))
    `(let (buffer-undo-list)   ;  maintain original buffer-undo-list
       (clone-indirect-buffer nil t)
       (let ((,return-value (progn ,@body)))
         (primitive-undo 1 buffer-undo-list)
         (kill-buffer-and-window)
         ,return-value))))

Here are two simple tests (first returns t, second returns nil):

(with-cloned-buffer
  (insert "A")
  (left-char 1)
  (looking-at-p "A"))

(with-cloned-buffer
  (insert "A")
  (left-char 1)
  (looking-at-p "B"))


texts: Enable visual-line-mode and org-indent-mode when opening org files

texts:
I'm new to emacs, org-mode. I have an org file which, every time I open, I have to enable the minor modes: visual-line-mode and org-indent-mode by hand using the M-x command.

I saw this question in stackoverflow and tried the following code in my .emacs file only to see an error when emacs loads.

Code

(require 'org-mode)
(defun turn-on-visual-line-mode () (visual-line-mode 1))
(add-hook 'org-mode-hook 'turn-on-visual-line-mode)

Error

Warning (initialization): An error occurred while loading ‘c:/Users/Prasanna Rajaram/AppData/Roaming/.emacs’:

File error: Cannot open load file, No such file or directory, org-mode

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

I did not try the org-indent-mode as I did not know how to turn on multiple minor modes with defun().


texts: cannot have a different default for font's height with emacs daemon

texts:
Following an article called Emacs, fonts and fontsets I was revising my font setup. I ended with the following code:

(defun font-exists-p (font)
  "Comprueba si una tipografía existe. Sacado de https://redd.it/1xe7vr"
  (if (member font (font-family-list))
      t
    nil))

(defun font-pt-to-height (pt)
  "Transforma una altura en puntos (pt) a altura de face-attribute."
  ;; el valor es de 1/10pt, por tanto 100 seria equivalente a 10pt, etc.
  (* pt 10))

(defun font-setup (frame)
  ;; tipografia por defecto
  (cond ((font-exists-p "Fira Code")
         (set-face-attribute 'default frame :family "Monospace" :height (font-pt-to-height 13) :font "Fira Code")))
  (cond ((font-exists-p "Apple Color Emoji")
         (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") frame 'prepend))
        ((font-exists-p "Symbola")
         (set-fontset-font t 'symbol (font-spec :size 20 :name "Symbola") frame 'prepend))))

(add-hook 'after-make-frame-functions #'font-setup t)
(add-hook 'emacs-startup-hook (lambda () (font-setup nil)))

but for some reason Emacs ran as a daemon keeps the defaults, see this screenshot:

If I manually run (font-setup nil) the default face change to what I want which is Fira Code (customize-face confirms to me the change to the default face happened)

I would like for my font setup configuration to be applied on the first frame and all the following frames.


texts: Emacs recover-session: which session should I recover?

texts:
My OS locked up while using Emacs.
So I hard boot, reopen Emacs, and M-x recover-session.
The OS locked up at Jul 6 3:05, there are two autosave sessions at 03:04

Which of the two 3:04 sessions should I use?

Also, please explain the right column.
What do the blue "site" and "dist" mean?
What does red strike-through mean?

I am using Emacs 25.2.1 with Evil Spacemacs and Ivy on Linux.


texts:
Emacs throws an error every time I use C-g to cancel a process. This is getting annoying.

Debugger entered--Lisp error: (quit)
  read-from-minibuffer("Switch to buffer: " nil (keymap (keymap (11 . ivy-switch-buffer-kill)) keymap (36 . ivy-magic-read-file-env) (3 keymap (19 . ivy-rotate-sort) (1 . ivy-toggle-ignore) (15 . ivy-occur)) (67108903 . ivy-avy) (33554464 . ivy-restrict-to-matches) (15 . hydra-ivy/body) (22 . ivy-scroll-up-command) (prior . ivy-scroll-down-command) (next . ivy-scroll-up-command) (7 . minibuffer-keyboard-quit) (right . ivy-forward-char) (32 . self-insert-command) (18 . ivy-reverse-i-search) (19 . ivy-next-line-or-history) (remap keymap (describe-mode . ivy-help) (kill-ring-save . ivy-kill-ring-save) (kill-whole-line . ivy-kill-whole-line) (kill-line . ivy-kill-line) (scroll-down-command . ivy-scroll-down-command) (scroll-up-command . ivy-scroll-up-command) (end-of-buffer . ivy-end-of-buffer) (beginning-of-buffer . ivy-beginning-of-buffer) (kill-word . ivy-kill-word) (forward-char . ivy-forward-char) (delete-char . ivy-delete-char) (backward-kill-word . ivy-backward-kill-word) (backward-delete-char-untabify . ivy-backward-delete-char) (delete-backward-char . ivy-backward-delete-char) (previous-line . ivy-previous-line) (next-line . ivy-next-line)) (9 . ivy-partial-or-done) (10 . ivy-alt-done) (27 keymap (1 . ivy-read-action) (15 . ivy-dispatching-call) (111 . ivy-dispatching-done) (25 . ivy-insert-current-full) (105 . ivy-insert-current) (106 . ivy-yank-word) (114 . ivy-toggle-regexp-quote) (97 . ivy-toggle-marks) (16 . ivy-previous-line-and-call) (14 . ivy-next-line-and-call) (118 . ivy-scroll-down-command) (112 . ivy-previous-history-element) (110 . ivy-next-history-element) (10 . ivy-immediate-done) (13 . ivy-call)) (mouse-3 . ivy-mouse-dispatching-done) (mouse-1 . ivy-mouse-done) (down-mouse-1 . ignore) (13 . ivy-done)) nil ivy-history)
  ivy-read("Switch to buffer: " internal-complete-buffer :keymap (keymap (11 . ivy-switch-buffer-kill)) :preselect "SOP.org" :action ivy--switch-buffer-action :matcher ivy--switch-buffer-matcher :caller ivy-switch-buffer)
  ivy-switch-buffer()
  funcall-interactively(ivy-switch-buffer)
  #<subr call-interactively>(ivy-switch-buffer t nil)
  elmacro-record-command(#<subr call-interactively> ivy-switch-buffer nil nil)
  apply(elmacro-record-command #<subr call-interactively> (ivy-switch-buffer nil nil))
  call-interactively(ivy-switch-buffer nil nil)
  command-execute(ivy-switch-buffer)

Anybody knows what's happening over here?


texts: Dired+: Not enter in folder when window is split

texts:
Windows 10, Emacs 25.1., Dired+

I want to copy file from folder "test" to folder "response".

My steps:

Open folder "test"
see screen:

split window by command (split-window-vertically &optional SIZE)
see screen:

Now I want enter in folder "response". As result I

move cursor to bottom screen by (windmove-down &optional ARG)
Press "Return"
As result top window go to prev buffer (scratch)

see screen

Why? And how I can fix this?

Updated (from mistaken update of an answer by question OP - moved here):

I think I narrow the problem. My steps:

 emacs -Q

Load only dired+

 (require 'dired+)

The prblem is GONE. ОК.

In my init.el I has the next diredp setting:

 ;; Dired reuse directory buffer (only one buffer)
 (diredp-toggle-find-file-reuse-dir 1)

So I set it.

And ... the the problem reappeared. So I think the problem is in dired+ package and specifically in this setting

 (diredp-toggle-find-file-reuse-dir 1)

Is I'm right?


texts: Syntax highlighting not working in Emacs (in Python mode)

texts:
When I Python-mode I have noticed that occasionally my syntax highlighting is not working.

I have noticed this when using the Cyberpunk theme as well as the Tango-Dark theme.

Closing and reopening the file corrects the highlighting for any previously written code but it remains broken for any new code.

I do not know how to debug this or what the issue could be so I would be very appreciate of any help.

Here you can see an example (only #Plan route) should be grayed out.


texts:
Q: is there a predicate function for dotted pairs?

In other words, is there a function that distinguishes between dotted pairs and 2-element proper lists:

(some-predicate-p '(a . b))             ; => t
(some-predicate-p '(a   b))             ; => nil

The broader context: I need to access the second element of a pair of values, and would like the function to "do the right thing" when it's fed either a dotted pair or a 2-element proper list:

(cdr  '(a . b))                           ; => b
(cadr '(a   b))                           ; => b

Since cdr and cadr cannot be dropped in interchangeably between proper and improper lists:

(cadr '(a . b))                           ; => error
(cdr  '(a   b))                           ; => (b)


texts: How to count direct or indirect children in org or outline mode

texts:
I want to count the number of children in a subtree in org-mode. I am able to count the number of recursive children with (outline-next-heading):

(defun outline-count-subheadings (&optional recursive)
  "Count the number of subheadings below the current heading."
  (interactive)
  (let ((sum 0)
        (end (save-excursion
               (ignore-errors
                 (outline-end-of-subtree)
                 (point)))))
    (when end
      (save-excursion
    (outline-next-heading)
    (setf sum 1)
        (while
        (< (point) end)
      (progn
        ;; todo: add conditional for recursive argument
        (outline-next-heading)
        ;;(org-forward-heading-same-level 1 nil) ; this does not terminate
        ;;(outline-forward-same-level 1) ; this errors with "No following same-level heading"
        (setf sum (1+ sum))))))
    (message (concat "Number of subheadings (" (if recursive "descendants" "direct children") "): " (format "%d" sum)))))

But for direct children (org-forward-heading-same-level 1 nil) does not terminate the loop and (outline-forward-same-level 1) errors with No following same-level heading.

What am I doing wrong?


texts:
In my document, I have an em dash that needs to be followed by italics. Here's a minimal example:

He was surprised—/excuse me/?

The LATEX/PDF output includes the slashes and the text is not italicized. How can I resolve this without adding spaces? This is a quote, so I can't change the text.


texts: Confirm quit only for keyboard shortcut, not for window close via mouse

texts:
I activated setq-local confirm-kill-emacs (quote y-or-n-p) on a hook for a local mode which has a shortcut very similar to C-x C-c, in order to avoid accidentally closing Emacs when trying to execute the said shortcut. That way, Emacs will ask me to confirm it and I will be able to cancel it.

But this has an unfortunate consequence, that is, when I click on the close button on the top of Emacs' window, it also asks the same question. This is often annoying.

Is there a way to only ask for confirmation when using the keyboard shortcut, but not the mouse click?


texts: elpy-importmagic-add-import without rearranging imports?

texts:
The auto-importing functionality of elpy is awesome. However, it rearranges all the previous import statements in the file alphabetically. This is problematic for me because:

I prefer to arrange my imports this way according to pep-8

Imports should be grouped in the following order:

standard library imports
related third party imports
local application/library specific imports

You should put a blank line between each group of imports.

More importantly, I don't want the unecessary changes in my commits when existing imports are rearranged.

Is there any way to customize how imports are arranged, or to have them not be rearranged at all? I am assuming that if it doesn't rearrange them, it will not know where to put the new import, so the former option would probably be preferable. Thanks for any suggestions!
EDIT:
On further investigation, it seems like it is trying to arrange imports according to pep-8, but doesn't seem to recognize my "local application/library specific imports" as such.


texts: How to always show buffer in the new created frame?

texts:
My workflow is:

I initialize emacs with a shortcut (in my ~/.i3/config I have a line like this bindcode $mod+49 exec emacsclient -c -n -q -a=''. I use i3wm.org)
By default it goes to temp.org, in .emacs is (setq initial-buffer-choice "~/org/temp.org"), which is useful to do temp notes
But sometimes I want to edit an existing file, I use C-x C-f ((ido-mode 1)
 is enabled in .emacs), most of them, org files. I have very large (at least for me) org files that are part of my personal documentation. I can open the same file different times, when this happen I would like to have (and initialize) the same buffer in different frames (I see this as a good default behavior), but I never cannot do that, what happens is that switches (reuses) to the frame where the buffer is.

Example of my problem.

Given: Frame1-temp.org Frame2-thing.org
Action: in Frame1 I do C-x C-f thing.org
Consequence: focus switches from Frame1 to Frame2 (because there is thing.org)
Result: Frame1-temp.org Frame2-thing.org

Example of what I would like.

Given: Frame1-temp.org Frame2-thing.org
Action: in Frame1 I do C-x C-f thing.org
Consequence: Frame1 displays thing.org
Result: Frame1-thing.org Frame2-thing.org

Applying over and over this workflow I end up with lots of temp.org emacs frames opened, that I close using a bash alias: alias killtemp='i3-msg [title="^temp.org.*"] kill'

emacs version: GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2019-05-27


texts: Composing a regexp to highlight folder extensions differently

texts:
I am having difficulties composing a regexp that will highlight certain folder extensions -- including the preceding dot -- with colors that are different than the rest of the folder -- e.g., .app would be colored red; and .git would be colored blue.

Examples:

The folder Emacs.app would be colorized with Emacs being a gray color and .app would be a red color.
The folder .0.context-menu.git would be colorized with .0.context-menu being a gray color and .git would be a blue color.

I have a regexp that gets me from the left margin all the way to the beginning of the folder -- the variable for that regexp is named folder-listing-before-filename-regexp.

The problem I am having is that the regex .* swallows up the folder extensions.  If I add [^.], that prevents me from using the dot later on with extensions like .app and .git -- I want the extension to include the dot when colored.

The regexp that leads up to the folder looks like this:

(defvar folder-listing-before-filename-regexp
  (concat
    "\\(^ +d[slrwxt+-]+\\)"    ;; 1  permissions
    "\\(\s\\)"                 ;; 2
    "\\([0-9]+\\|\s+[0-9]+\\)" ;; 3  some small numbers
    "\\(\s\\)"                 ;; 4
    "\\([a-zA-Z]+\\)"          ;; 5  group
    "\\(\s\\)"                 ;; 6
    "\\([a-zA-Z]+\\)"          ;; 7  user
    "\\(\s\\)"                 ;; 8
    "\\([\s0-9.kKMGT]+\\)"     ;; 9  size
    "\\(\s\\)"                 ;; 10
    "\\([0-9-]+\\)"            ;; 11 date
    "\\(\s\\)"                 ;; 12
    "\\([0-9:]+\\)"            ;; 13 time
    "\\(\s\\)"))               ;; 14

Here is some test data:

  drwxr-xr-x  79 HOME staff 2.7K 10-30-2014 16:42:18 .
  drwxr-xr-x  27 HOME staff  918 10-28-2014 13:08:59 ..
  drwxr-xr-x 162 HOME staff 5.4K 10-11-2014 11:34:16 .0.apel_flim_simi
  drwxr-xr-x 432 HOME staff  15K 10-29-2014 15:37:44 .0.backup
  drwxr-xr-x   5 HOME staff  170 10-19-2014 09:34:37 .0.context-menu.git
  drwxr-xr-x   5 HOME staff  170 10-19-2014 13:06:36 .0.dired-read-filename.git
  drwx------   4 HOME staff  136 04-29-2014 17:40:13 .0.eshell
  drwxr-xr-x   3 HOME staff  102 10-11-2014 10:29:03 .0.gh
  drwxr-xr-x   5 HOME staff  170 10-09-2014 21:16:35 .0.lorg-calendar.git
  drwxr-xr-x   5 HOME staff  170 10-09-2014 20:06:09 .0.lorg-search.git
  drwxr-xr-x  10 HOME staff  340 01-31-2014 19:37:31 .0.mail
  drwxr-xr-x  25 HOME staff  850 10-14-2014 13:23:31 .0.snippets
  drwxr-xr-x  23 HOME staff  782 12-03-2013 17:15:50 .0.sound
  drwxr-xr-x  27 HOME staff  918 10-18-2014 11:53:56 .0.sources
  drwxr-xr-x  67 HOME staff 2.3K 05-05-2014 23:19:12 .0.w3m
  drwxr-xr-x 146 HOME staff 4.9K 09-08-2014 10:54:40 .0.wl
  drwxr-xr-x   3 HOME staff  102 06-03-2014 11:37:02 Emacs.app
  drwxr-xr-x   3 HOME staff  102 06-01-2014 10:39:02 Emacs_06_01_2014.app
  drwxr-xr-x   3 HOME staff  102 10-01-2014 07:31:45 Emacs_10_01_2014.app
  drwxr-xr-x 195 HOME staff 6.5K 10-18-2014 12:06:25 bin
  drwxr-xr-x   3 HOME staff  102 06-26-2013 07:59:44 etc
  drwxr-xr-x  10 HOME staff  340 09-30-2014 18:07:42 include
  drwxr-xr-x   9 HOME staff  306 06-05-2013 22:50:05 info
  drwxr-xr-x  27 HOME staff  918 10-18-2014 12:06:42 lib
  drwxr-xr-x  12 HOME staff  408 09-30-2014 18:10:42 libexec
  drwxr-xr-x   4 root staff  136 09-30-2014 18:07:42 man
  drwxr-xr-x   4 root staff  136 09-30-2014 18:10:42 sbin
  drwxr-xr-x   9 HOME staff  306 09-30-2014 18:10:42 share


texts: Specify the order in which `defcustom`s are presented in the Customize UI?

texts:
I have an Emacs mode. It has a defgroup and a number of defcustoms. Let's say:

(defgroup some-group nil
  "Some group"
  :prefix "prefix-"
  :group 'languages)

(defcustom some-option-1 t
  "Option 1"
  :tag "Option 1?"
  :type 'boolean
  :group 'some-group)

(defcustom some-option-2 t
  "Option 2"
  :tag "Option 2?"
  :type 'boolean
  :group 'some-group)

(defcustom some-option-3 t
  "Option 3"
  :tag "Option 3?"
  :type 'boolean
  :group 'some-group)

All works fine, except the order in which these appear in the Customize buffer shown by M-x customize is not the order the defcustoms appear in the source, or alphabetically by their identifier, or alphabetically by their :tag -- or any other pattern I've been able to figure out so far. For example the options above might end up in the UI as 3, 1, 2. But I'd like them to appear as 1, 2, 3.

The same seems true for the order of sub-groups.

Is there a way I can make them appear in an order that I specify, and if so, how?

(This with Emacs 24.3, in case that's relevant.)


texts:
(require 'flycheck)
(add-hook 'js2-mode-hook
          (lambda () (flycheck-mode t)))

Used this, to setup flycheck for javascript development. However, i noticed config changes in .jshintrc is not considered at all for error highlighting (setting asi as true to suppress missing semicolons is one such case.)
Later, i saw that js2-mode has inbuilt support for error highlighting. So, what set of rules js2-mode and is it as customizable as flycheck-jshint?


texts: Does icicles offer features that Helm doesn't?

texts:
I'm an avid helm user and am reading the description for icicles. It includes things like:

  cycle through completion candidates that match your current input *

which sounds weaker to me than seeing the entire list of matches in helm (since I'm willing to have a buffer open up like that)

  use a pattern to match completion candidates, including:

which is exactly a Helm feature, etc.

So Icicles sounds like a good package but it seems to be a direct competitor to Helm, and in exploring Icicles, I haven't found a reason to install it given that I have Helm. What features might I be missing?


texts:
I just discovered vlf-mode (View Large Files) and I am using it to view a large binary file in hexl-mode and read certain metadata from headers within the file.  It works great, with one exception. When I move to another "batch" within the file, hexl-mode starts the addresses of the next batch at 0x00000000 which makes it hard to know which byte I am actually at.

Are there existing solutions for viewing large binary files but maintaining information about the absolute "address" of a given line?


texts: How to prevent Magit from saving COMMIT_EDITMSG?

texts:
When I hit c c in the Magit buffer it opens the commit message buffer. Then I write my message and type C-c C-c to close it. For some reason it saves .git/COMMIT_EDITMSG and every next time when I hit c in the Magit buffer it opens .git/COMMIT_EDITMSG instead of commit popup.

Does it have anything to do with Magit itself or is this somewhere in my git setup?


texts: Emacs + visual line numbers + folding + visual fill column mode

texts:
Relative line numbers for me it's a little bit painful topic. I'm using evil (spacemacs) and I want to jump between lines by in vim style like 10j, 4k etc.
Is it possible to get line numbers behavior in emacs just like in vim?

There is two mutually exclusive problems for visual and relative line numbers mode in emacs.

Visual line numbers works great with folding. But when test wraps by visual-fill-column-mode, visual line numbers assigns a number to non-existent line. And from now I can't just moving between lines correctly because of related picture.

In another hand relative line numbers solve the problem above, and it works just fine, but... until the moment when I fold something. Imagine, in picture below I want jump to one of Another long test topic. How should I do this?

So, is there any solution for this? I've spent a lot of time to googling it, but my efforts still have no result.

Sorry for my English.
Regards


texts: How to set Org-mode heading color for level after 8?

texts: I can only set color and font-face for Level between 1 to 8. Is there a way to set heading color for Org Level 9 and beyond?


texts: How to examine the new line characters in emacs?

texts:
I want to check if there is a "\r" at the end of a line of a plain text file (compressed as .gz file). I try the whitespace mode, and I don't find ^M shown. Is \r shown as ^M in whitespace mode?

But my python program says something is wrong with the 1 at the end of the second line
line 67, in transform
    vals = [eval(v) for v in line.replace('\n', '').split(',')]
  File "<string>", line 1
    1
    ^
SyntaxError: unexpected EOF while parsing

Did I use emacs correctly to show the \r, \n and other characters at the end of each line?
Thanks.


texts:
There's some stuff in the mode-line that's "global", not particular to that buffer, e.g. date-time-load, org-clock task and erc-track. If split-window-right, that stuff is both duplicated and truncated in the same way in both windows, e.g. here the org clock task name is truncated (scroll right to see the duplication):

27: 0 U ~/foo.el Top Elisp 12:19 [#ha] [1:31] [Procrast| 99: 0 U ~/foo.el 83% ELisp 12:19 [#ha] [1:31] [Procrast

Is there a way to truncate only the "global" stuff such that I get as much information as possible? E.g.

27: 0 U ~/foo.el Top Elisp 12:19 [#ha] [1:31] [Procras…| 99: 0 U ~/foo.el 83% Elisp 12:19 …tination]

(scroll right to see the non-duplication)


texts: How to save offline copy articles in gnus; Speed up large groups

texts:
Earlier today I added gwene as a backend for gnus.

(add-to-list 'gnus-secondary-select-methods '(nntp "news.gwene.org"))

I then added a few feeds that I wanted to read and keep up to date on. One of which was gmane.emacs.devel. This group has over 200,000 articles/messages and every time I want to read an article it seems to download all 200,000. This takes an incredible amount of time.

I read about how gnus can cache articles and that seems very promising. The manual though said that it was bad practice, but I went ahead and tried the code that they suggested (setq gnus-use-cache t). This had no effect though.

Long story short my question is: how can I save an offline copy of a mailing list for fast access and offline use, using gwene or something else.

Thank you.


texts: Is that possible to make priority C higher than B?

texts:
From: https://orgmode.org/manual/Priorities.html

  You can change the range of allowed priorities by setting the
  variables org-highest-priority, org-lowest-priority, and
  org-default-priority. For an individual buffer, you may set these
  values (highest, lowest, default) like this (please make sure that the
  highest priority is earlier in the alphabet than the lowest priority):

  #+PRIORITIES: A C B

Pay attention to this:

  (...) please make sure that the highest priority is earlier in the alphabet
  than the lowest priority

Is not possible to define, for example, the following order: A, C, B and D?

If I use the org-mode API The priority A always has a smaller number than B, and B than C and so on.

I use this matrix:

Where A is urgent and important. B is important but not urgent. And C is urgent but not important. So, C should be "higher priority" than B because it should be done first.

Is that possible to invert the order of priority letters? A, C, B and D? Or not?


texts: Programmatically check whether a unicode character will render as tofu

texts:
Is there a way to programmatically determine whether a given unicode character will render as tofu in some context in Emacs?

Some bug-flavored (U+1F41B) tofu renders in a face using DejaVu Sans Mono:


texts:
How to create a toggle button in the modeline, like a play / pause button ?
for now, I've got the following :

(setq-default mode-line-format
      '(
    (:eval
      (propertize
      " ⏸ "
        'local-map (make-mode-line-mouse-map 'mouse-1 'helm-spotify-plus-toggle-play-pause)
      )
    )

))

And I would like to toggle play and pause unicode characters.


texts: New bidi problems with outline-mode / org-mode (Arabic, Hebrew,..)

texts:
Some time ago (maybe 3 months) I've noticed some problems with the bidi support (right-to-left languages) in org-mode.
One problem I can't reproduce: The characters have then a strange form but If I change the text scale (larger or smaller) it becomes normal.
The second problem I can reproduce, you can see it in the two images:
In this image: I have the option bidi-paragraph-direction: nil (the same if I put in the first line: -*- mode: outline -*-), to get the right direction for  Hebrew and Arabic. As you see the headline color isn't consistently brown. The English text don't have this problem.

In this image without the option: Everything is ok:

In both examples my init file is empty. And I've tried many fonts. My org version is 9.3 and emacs version is 27.1.
Actually, the first problem is bigger for me but I can't reproduce it; I think that both problems appeared a the same time. So maybe solving the second will solve the first one too(?)
EDIT: I can reproduce the problem with the colors also on a Windows machine with latest version: emacs 27.1 and the included org 9.3. With the older version: emacs 26.3 and the included org-version 9.1.7 I don't have the problem - at least I didn't see it.
EDIT 2: The same problem happens in outline-mode. So maybe it's not an org-mode problem. (Thanks to Samim Pezeshki)


texts: Emacs: how to open and play a video file

texts:
If I am exploring my file system in Dired-mode and I come across a video file, for example, it would be nice to be able to play that video file. How can I do this in Emacs?

I can use Emacs to open a video file, but the result is not very useful - I just get the encoded file displayed as text. Is there a way the Emacs can play video files, or perhaps link it to a command that has another program like vlc play the file?


texts: mu4e Setup: cannot create messages outside the Drafts mailbox Error

texts:
I am attempting to setup mu4e to read mail from a Protonmail account. I'm using offlineimap to sync my mail dirs. However, when I try to refile or move a message from my INBOX folder to any other folder that I sync with the server I get an error like this in offlineimap:
Server responded: NO ['cannot create messages outside the Drafts mailbox']

I'm surprised that there's not much that I can find on this error. Since it doesn't seem to be a common offlineimap error I have to wonder if it has something to do with the way that mu4e moves messages around?
Here's how I can reproduce the error:

Receive a new message in my inbox
Sync my local maildir with my Protonmail account successfully using offlineimap (which points at a hydroxide process)
Run mu index
Open mu4e and refile the message to my Archive folder
Attempt to sync my mailbox again using offlineimap

Here is my .offlineimaprc file:
# ~/.offlineimaprc

[general]
accounts = protonmail
pythonfile = ~/.config/offlineimap/keyring.py
metadata = ~/.cache/offlineimap

[Account protonmail]
remoterepository = protonmail-remote
localrepository = protonmail-local

[Repository protonmail-local]
type = Maildir
localfolders = ~/.mail
sync_deletes = yes

[Repository protonmail-remote]
# delete local mails that were deleted on the remote server
expunge = yes
type = IMAP
remotehost = 127.0.0.1
remoteport= 1143
remoteuser = tompurl
remotepasseval = get_password("tompurl@protonmail.com")

folderfilter = lambda foldername: foldername in ['INBOX', 'Archive', 'Sent']
ssl = no

...and here's my mu4e config:
(add-to-list 'load-path "/home/tom/.nix-profile/share/emacs/site-lisp/mu4e")
(require 'mu4e)

(setq mu4e-maildir "~/.mail"
      mu4e-attachment-dir "~/Downloads")

(setq mu4e-sent-folder   "/Sent")
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-refile-folder "/Archive")
(setq mu4e-trash-folder  "/Trash")

(setq user-mail-address "tom@tompurl.com"
      user-full-name  "Tom Purl")

;; Get mail
(setq mu4e-get-mail-command "offlineimap"
      mu4e-change-filenames-when-moving nil
      mu4e-update-interval nil)

;; Send mail
(setq message-send-mail-function     'smtpmail-send-it
      smtpmail-auth-credentials "~/.authinfo.gpg"
      smtpmail-smtp-server "127.0.0.1"
      smtpmail-smtp-service 1025)

Here's what I've tried:

Set mu4e-change-filenames-when-moving to true, which is apparently necessary for mbsync but not offlineimap.
Set sync_deletes in my .offlineimaprc file to "no".

Otherwise I'm just stumped. I'm surprised that this isn't a much more common error because my setup is pretty vanilla.


texts: How can I automatically block out "free time" in an org-agenda view?

texts:
Was just thinking. I've noticed a lot of people schedule their free time in to their agendas/planners.
I think it would be useful to automatically schedule out free time when opening the agenda. For example, if I have schedule tennis practice, and a meeting, my current agenda would like like this:
8:00-10:00 Scheduled: Tennis Practice

16:30-18:00 Meeting

Whereas, it could look like this:
8:00-10:00 Scheduled: Tennis Practice

10:00-16:30 Free

16:30-18:00 Scheduled: Meeeting

18:00-20:00 Free

...without having to schedule to free time explicitly.
To me, this is a lot easier to comprehend than the above time graph, particularly since I find looking at my watch more useful than the time grid.
How can I do this?


texts: Managing Emacs key-bindings in other applications?

texts:
I'm relatively new to Emacs and like it a lot, especially the navigation commands such as: C-e, C-a, C-f, M-f, C-n, C-p, etc.

Unfortunately, I often find myself trying to use them in other applications like Microsoft Office, Internet Browsers, etc. without success.

The key bindings sometimes work, such as C-e, C-a, C-n, C-p while I'm writing in the Safari Browser on OSX. But most other applications don't do this and I find it quite perplexing.

It gets even more confusing if you are using several operating systems. In Microsoft Windows, the Control key is used for all standard commands, so C-n usually creates a new document or C-p for printing, while on OSX the Alt or Cmd key is blocked for those. So to get a consistent set of key bindings on Windows and OSX and Emacs seems very difficult without at least breaking the most basic standards of one of those operating systems.

Q: How do you manage to do this on most operating systems?

Do you redefine key bindings also in other applications to match those of Emacs?
Or do you redefine standard key bindings in Emacs to avoid conflicts with standard key bindings of the operating system?


texts: Can't install Plantuml-mode -- MELPA Package list Incomplete (Mac)

texts:
I'm trying to install plantuml-mode based on the instructions here:

https://github.com/skuro/plantuml-mode

I'm told to try the following:

M-x package-install<RET>
plantuml-mode<RET>

But the package isn't found:

Contacting host: elpa.gnu.org:80
Failed to download ‘gnu’ archive.

However, it is listed here on MELPA:

https://melpa.org/#/plantuml-mode

I don't have much experience installing things in Emacs.  Is there some fool-proof way to get this installed on my mac, possibly with a 'recipe'?

I do have plantuml installed.


texts: How do you define constants in an emacs dynamic module?

texts:
I am trying to write a dynamic module to expose some constants in the GNU Scientific Library. I thought something like this would do it.

#include <gsl/gsl_const_mksa.h>
#include "emacs-module.h"

int plugin_is_GPL_compatible;

int emacs_module_init(struct emacs_runtime *ert)
{
  emacs_env *env = ert->get_environment(ert);

  emacs_value defconst = env->intern(env, "defconst");

  char doc[] = "Speed of light in vacuum (m/s).";
  emacs_value args[] = {
    env->intern(env, "GSL-CONST-MKSA-SPEED-OF-LIGHT"),
    env->make_float(env, GSL_CONST_MKSA_SPEED_OF_LIGHT),
    env->make_string(env, doc, sizeof doc)
    };

  env->funcall(env, defconst, 3, args);

  // This is what allows the shared library to provide a feature
  emacs_value provide = env->intern(env, "provide");
  emacs_value provide_args[] = { env->intern(env, "gsl-constants") };
  env->funcall(env, provide, 1, provide_args);

  return 0;
}

This compiles fine with

gcc -Wall -I/usr/local/include -fPIC -c gsl-constants.c
gcc -shared -L/usr/local/include -lgsl -o gsl-constants.so gsl-constants.o

But something is not working because I get "Required feature ‘gsl-constants’ was not provided" if I try to (require 'gsl-constants).

I guess that something is wrong with the defconst part because if I comment that out, it requires fine. Does anyone know if there is another way to define constants or variables in a dynamic module?


texts:
When I search through project via semantic-complete-jump and tag is not unique (its defined in multiple places), I must hit <tab> to iterate through all possible places. Problem is, I horribly dislike the way how candidate iteration works. For every candidate definition, new window is opened.

How to customize it to not open additional windows?

And even better, how to get needed data from semantic so I can create my own semantic-complete-jump with IDO interface.

Basically, I want this "theoretical" function which I failed to find when reading CEDET sources around semantic-complete-jump.

INPUT: name of symbol (function name, member name etc).

OUTPUT: list of files with positions where such symbol is defined in current project.

Again, I tried to read sources and was unable to find how this data are extracted from semantic.


texts:
Is there a way to get Jedi to perform completion for Cython?  One can simply use normal jedi completion; however, it does not work on Cython keywords such as cdef or when importing Cython modules (e.g. "import partial_module_name|").

If there's no reasonable way to get Jedi to do this, is there some other package that does this?  I'm already combining another method of completion with Jedi's completion by writing a completion-at-point function that calls jedi:ac-direct-matches, so it would be easy to add another for Cython.


texts:
How do I remap the lsp-mode prefix key to "s-k" using the use-package package?
I tried the following
(use-package lsp-mode
  :ensure t
  :init
  (setq lsp-keymap-prefix (kbd "s-k")

 (use-package
 [...]
 :bind
 ("s-k" . lsp-keymap-prefix)

 (use-package
  [...]
 :bind (:map lsp-command-map
 ("s-k" . lsp-keymap-prefix))

I don't seem to understand how this works. What am I doing wrong?
EDIT 1:
I am not sure if I should open a new issue for this.
I followed the suggested solutions without success, when another issue occured:

Error (use-package): Failed to parse package lsp-mode: Wrong type
argument: listp, lsp-keymap-prefix

Whene using emacs --debug-init, I get
Debugger entered--Lisp error: (void-variable personal-keybindings)
  byte-code("\3061\247\0\307\310N\206\13\0\311\307\312\"\210\313\310N\206\26\0\311\313\10\"\210\313\310N\206!\0\311\313\11\"\210\314\315!\2042\0\316\315\317\320\321$\210..." [read-process-output-max lsp-idle-delay name key kmap kdesc (debug error) gc-cons-threshold custom-set set-default 100000000 setq fboundp lsp autoload "lsp-mode" nil t lsp-command-map add-hook c++-mode-hook "s-k" vectorp read-kbd-macro key-description lookup-key assoc add-to-list personal-keybindings define-key :catch global-map binding details entry err use-package--warning1] 6)
  require(setup-lsp-mode)
  eval-buffer(#<buffer  *load*> nil "/home/nry/.emacs" nil t)  ; Reading at buffer position 1076
  load-with-code-conversion("/home/nry/.emacs" "/home/nry/.emacs" t t)
  load("~/.emacs" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x158e8a4509ed>) #f(compiled-function () #<bytecode 0x158e8a450a01>) t)
  command-line()
  normal-top-level()

After a little more investigations, it turns out that this happens every time I use :bind, I had to comment out the :bind- statements from other packages as well to get rid of the error message. This was not the case before I started to change the prefix key! All I did was playing around with the bind-statements, like
(setq lsp-keymap-prefix (kbd "s-k")

and
  :bind
  ("s-k" . lsp-command-map) ;; not working

  :bind-keymap
  ("s-k" . lsp-command-map)

I set everything back as it was, but the error message stays (if I use :bind in other packages like e.g. company). But it ONLY stays, if I byte compile my directory. If I only use the .el files, no error occurs. It feels like I broke my config or the use-package package. Any sugggestions?
EDIT 2:
I found the solution to the issue describe in EDIT 1. I had to add
(eval-when-compile
  (require 'use-package))

to my .emacs file.
Also, changing the prefix-key was solved as well with:
  :bind-keymap
  ("s-k" . lsp-command-map)

Cheers


texts: How can I use company's ignore-case with pip-requirements.el

texts:
I am looking for a way to ignore case when discovering packages through company's completion with pip-requirements.el only.

Edit:
Using completion-ignore-case, "breaks" the highlight of candidates:


texts: Multiple replacements for directories in init file

texts:
Now, I've checked many questions here to get an answer for what I want, but every question seems a bit different that that what I need. I use org-babel to create an init file. I often change my config and want to use it on multiple machines. Most path in the .org are relative to the home so no problem there, but some are not and some can't even deal with relative path since they are used in a shell script. So I want to define path-replacement variables at the the beginning.

Example:
System 1:

(setq org-download-screenshot-file "Z:/Temp/screenshot.png")
(setq org-ditaa-jar-path "Z:/Tools/Ditaa/ditaa0_9.jar")

System 2:

(setq org-download-screenshot-file "C:/Temp/screenshot.png")
(setq org-ditaa-jar-path "C:/!Portable/Ditaa/ditaa0_9.jar")

What I need is something like:

(setq my-relative-path-one "Z:/Temp")
(setq my-relative-path-two "Z:/Tools/Ditaa")

So I can use the configuration below for both systems, just replacing the value of my-relative-path-xxx would be needed. I would then place the path matching variables in a different org file which is loaded before the main org configuration file. This would allow me to sync the main configuration file without paying attention to the path values.

(setq org-download-screenshot-file "my-relative-path-one/screenshot.png")
(setq org-ditaa-jar-path "my-relative-path-two/ditaa0_9.jar"

Thanks for any suggestion.
With kind regards,
Jens Lange


texts: Can helm `find-file` in the parents directory automatically?

texts: With ido-find-file, if the file I am looking is not in current directory but in the parents directory, it can automatically find it as candidate. I am not sure if helm can do the same thing?


texts:
Lets say I want to color a particular org-level-heading with a code as below

(set-face-attribute 'org-level-1 ((t (:background "linen") ) ))

The uncollapsed heading will look like

However, when the heading collapses we have (my background is white)

I want it to be such that the entire line is colored by the background color defined by the org-level even when the heading level is collapsed. And I am not sure which variable to edit in order to make that happen.

Secondly, when I add my todos, the heading looks as follows

I tried to figure out how to force the todo states to take the background color of the heading while keeping rest of their formatting but was unable to do that too.

I have searched for this for a while but was unable to find anything, either knowing the solution or that the solution does not exist would both make me happy. Any solution or hints would be greatly appreciated.


texts: Org mode: how to set a deadline to an already appointed meeting date

texts:
I'm kinda new to org-mode and I was wondering whether it is possible to set a deadline for a TODO task to a meeting date? I try to be more specific in the following:
I have a meeting org file within which I keep all my meetings dates under headlines (ie. no SCHEDULED nor DEADLINE): appointments.org :
* Meeting with boss <2021-01-25>
* Meeting with John <2021-02-03>

What I would like when associating a DEADLINE date to a TODO in another org file, is to interactively select a specific meeting that my task corresponds to in my appointments.org (in that case 'Meeting with boss'). This way, the date of the TODO DEADLINE could be dynamically linked to that of the meeting: should the meeting's date change, the TODO DEADLINE would also shift:
* Tasks
** TODO Do something for boss
DEADLINE: <????-??-??> <-- select "* Meeting with boss" within appointments.org
** Other Task

So far nothing like this showed up in my researches, at least no "build-in" features.
Thanks for any feedback on this!


texts: Is a Lisp program in both prog-mode and lisp-mode?

texts:
Upon reading (emacs) Program Modes:

  Entering a programming language mode runs the custom Lisp functions
  specified in the hook variable prog-mode-hook, followed by those
  specified in the mode's own mode hook (see Major Modes). For instance,
  entering C mode runs the hooks prog-mode-hook and c-mode-hook. See
  Hooks, for information about hooks.

Does it mean that C programming is running under prog-mode and c-mode?

Is prog-mode a universal mode for all the programs?

It additionally implies that prog-mode is a major mode like c-mode.

Nevertheless:

  Major modes are mutually exclusive; each buffer has one and only one major mode at any time.

(from (emacs) Modes)

What does prog-mode do here, is it a minor mode but stated vastly in the major mode part?


texts: js-comint mode (node) returning too many undefined responses?

texts:
I am using js2-mode and comint-mode to run the Node REPL in emacs.  For some reason the prompt is returning a lot of undefined and ...undefined responses, which it wouldn't do normally.  for instance, this code:

function run () {
    console.log('hello there');
}
function next () {
    console.log('hello again');
}

run();
next();

Prints out the following:

... ... undefined
> undefined                                                                                ... ... undefined                                                                                > undefined
> hello there
undefined
> hello again                                                                                undefined


texts: Magit commit error: "cannot spawn sh" + "cannot start editor"

texts:
When I try to commit using Magit, I get the following error message:

  1 c:/Users/chanyoungs/AppData/Local/GitHub/PortableGit_f02737a78695063deace08e96d5042710d3e32db/cmd/git.exe … "commit" "--"

  error: cannot spawn sh: No such file or directory

  error: unable to start editor '"c:/Users/chanyoungs/Documents/Programming/emacs/emacs-25.1/bin/emacsclient.exe"'
  Please supply the message using either -m or -F option.

Here are my settings:

Windows 10 64bit
GNU Emacs 25.2.1 (x86_64-w64-mingw32)
of 2017-04-24
Magit ver. 20170425.638
Git ver. 2.11.0.windows.3
Running Daemon

Further checks:

When I call git on cmd, it is called successfully
When I call emacsclient on cmd, in is called successfully
I tried running emacs with no other packages and get the same error

I searched for this error around and there are similar questions but I can't fix this with their suggestions. May be I'm not doing this right.

Any help or suggestions will be much appreciated.


texts: AUCTeX/LaTeX - ERROR: Undefined control sequence. documentclass

texts:
I am using AUCTeX with the following configuration.

(require 'tex)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master "main")
(setq latex-run-command "pdflatex")

Trying to build my document with C-c C-a gives me the error

ERROR: Undefined control sequence.

--- TeX said ---
l.1 \documentclass{IEEEtran}

My main.tex file looks like this:

\documentclass{IEEEtran}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[ngerman]{babel}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{import}
\usepackage{url}
\def\UrlBreaks{\do\/\do-}
\renewcommand\_{\textunderscore\allowbreak}

\begin{document}

\title{foo bar}
\author{foo}
\maketitle

\begin{abstract}
\end{abstract}

\begin{IEEEkeywords}
  Blockchain
\end{IEEEkeywords}

% Einleitung
\import{./}{intro.tex}

\nocite{*}
\bibliographystyle{unsrt}

\bibliography{references}

\end{document}

Using pdflatex on the terminal is just working fine.

Why does my emacs say different? I though internally is just a pdflatex call and... violá.


texts: Is there a function built in that I can call (maybe via emacsclient) to start gnus with a particular server / group given a URI?


texts:
I'm trying to get Emacs to imitate Vim's EOL behavior. Namely at the end of line ("\n"), the cursor comes to a halt instead of progressing to the start of the next line.
The following works fine and dandy but the cursor gets stuck before empty lines:
(defun make-eol-intangible ()
  (interactive)
  (add-hook 'post-command-hook
    (lambda ()
      (when (and (point) (looking-at "\n"))
        (backward-char)) t t)))

I could put an additional condition that tests for (point) looking-back however Emacs docs mention that looking-back should be avoided, and is possibly deprecated. On that note it's probably less optimal to use looking-at either.
I would like some suggestions.

Amended function (doesn't work as expected):
(defun make-eol-intangible ()
  (interactive)
  (add-hook 'post-command-hook
    (lambda ()
      (when (and (eq (char-before (point)) ?\n)
                 (eq (char-after (point)) ?\.))
    (backward-char)))))

(make-eol-intangible)


texts: Code blocks that produce org tables to be later consumed by other code blocks

texts:
I am having a bit of trouble with code blocks that produce org tables to be later consumed by other code blocks. For example:

#+NAME: upper_air
#+BEGIN_SRC clojure :results output raw
  (clojure.pprint/print-table table)
#+END_SRC

will produce

#+RESULTS: upper_air
|      :m | :degree | :meter/second |      :degC | :millibar |
|---------+---------+---------------+------------+-----------|
|  1545.0 |   175.0 |         12.36 |  15.400001 |     850.0 |
|  3162.0 |   265.0 |          6.69 |        4.8 |     700.0 |

but what I would really like is

#+TBLNAME: upper_air
|      :m | :degree | :meter/second |      :degC | :millibar |
|---------+---------+---------------+------------+-----------|
|  1545.0 |   175.0 |         12.36 |  15.400001 |     850.0 |
|  3162.0 |   265.0 |          6.69 |        4.8 |     700.0 |

(note #+RESULTS vs. #+TBLNAME) so that subsequently I can do something like

#+BEGIN_SRC ipython :session  :var data=upper_air
import numpy as np

arr = np.array(data)
p = arr[:,4]
#+END_SRC

With the #+RESULTS result, the second code block will interpret the data
argument as a string instead of a data table and I will not be able to extract
the data in a straightforward way. I could convert the ASCII data to a Python data structure 'manually', but I would prefer org handle it for me :-) Is there a way for either the first code block to output a #+TBLNAME instead of #+RESULTS? Alternatively, can the second code block coerce the argument as an
org table instead of a string?


texts: Wrong default-directory when inside a tmux session

texts:
I'm trying to use tmux inside emacs for a long time.
I want to use it to attach to remote (long living) session.
Attaching to sessions works fine but I have some problems in my daily
workflow
because find-file does not work properly inside a tmux session.

To reproduce my problem:

M-x term

pwd

if you now do find-file (C-c C-j to enter line-mode, than C-x C-f) it
will start
at your current location. Change your directory using cd, than redo
find-file,
everything should look like expected.

Now create a tmux session inside your term

tmux new -s test

pwd ;; your current location (1)

find-file should start from (1)
now cd to another directory, do find-file and it will still starts at (1)

The reason for that is, that the variable default-directory is not
changed, when
changing the directory inside a tmux session.

Does anybody has an idea how to fix this?


texts: Org capture templates now take me to org file, not to previous buffer

texts:
All of a sudden (after changing computer but keeping same settings) my org capture templates take me to the org file where whatever is being captured will be stored, without the need for C-c C-c to save it and return to previous buffer. I have no idea this happened. Below is an example capture template.

To be clear, I want to go into capture, add whatever I want to capture (e.g. a todo item) via C-c C-c, then return to previous work, not be taken to where the todo or whatever it is will be saved.

(setq org-capture-templates
     '(("t" "Todo" entry (file "~/Dropbox/org/gtd.org")
         "* TODO %^{Description}\n SCHEDULED: %^{Scheduled}t\n %?\n %i\n %a")
))

EDIT (more detail):
1. I'm taken to a capture buffer. 2. I add the description and press RET. 3. I add the date by selecting and pressing RET. That return takes me to the gtd.org file, rather than leaving me in the capture buffer to do anything else, like add more detail, a deadline etc., then finalise with a C-c C-c and return to previous buffer. This appeared out of nowhere, with no change to my init.el. Is it some sort of conflict with a package update?

Emacs version 26.1 (9.0)
Org version 9.1.9


texts:
Following the
Mode Tutorial,
I /almost/ finished my own mode (my-mode). Now I only have the
problem, that my mode-map settings seem to be ignored:

(defvar my-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map [(return)] 'newline-and-indent)
    (define-key map [(meta-y)] 'imenu )
    (define-key map [(control-c) (control-c)] 'compile )
    map)
  "Keymap for `my-mode'.")

 ;;;###autoload
(define-derived-mode my-mode fundamental-mode "My"
  "A major mode for editing My files."
  :syntax-table my-mode-syntax-table
  (setq-local comment-start "// ")
  (setq-local comment-end "")
  (setq-local comment-start-skip "\\s<+\\s-*")
  (setq-local font-lock-defaults
              '(my-font-lock-keywords nil t)
              )
  (setq-local tab-width 2)
  (setq-local default-tab-width 2)
  (setq-local indent-line-function 'my-indent-line)
  (setq-local compile-command (my-compiler-command))
  (setq-local imenu-generic-expression
              '((nil "^\\s *EventList\\s +\\(\\sw+\\)" 1)) )
  )

The elisp-info tells me that:

• The new mode has its own sparse keymap, named `VARIANT-map`.
  `define-derived-mode` makes the parent mode’s keymap the
  parent of the new map, unless `VARIANT-map` is already set and
  already has a parent.

So I think that my map should be active. When I open a file that uses
that buffer, my-mode-map is defined:

my-mode-map is a variable defined in `my.el`.
Its value is (keymap
 (control-c keymap
            (control-c . compile))
 (meta-y . imenu)
 (return . newline-and-indent))

But (describe-key-briefly) tells me: C-c C-c is undefined

On my last post, I made the error that I didn't restart Emacs from
scratch, when reproducing this error. This time I did so and I still
see this behaviour...

Why is my map not active?


texts:
Is there a way to prevent emacs from folding the buffer menu?

Example, when I Control + 'right click' on a buffer I see a menu like this:

Buffer Menu
-----------
JavaScript >
XQuery >
Custom >
Others >

Sometimes, I have to look in under 2 or 3 submenus to find the file I'm looking for. I'd like just to see a list of all files, even if there are many.

I've tried customizing buffer menu but I did not see the option.


texts: importing contacts in bbdb from a csv file

texts:
I would like to import contacts from a csv file into bbdb. I bumped into bbdb-csv-import on melpa for that and, from the documentation, it seems that it allows for entry customization. I have only the group and the email addresses in the csv file.

my csv-file format looks like

group, email,
group1, abc@letters.org,
group2, 123@numbers.com

(defconst bbdb-csv-import-td
  '(
  (:group "group")
  (:mail "Primary Email")
  )
  "td format")

(setq bbdb-csv-import-mapping-table bbdb-csv-import-td)

M-x bbdb-csv-import-file imported all my entries but they are all with ???.

Any help please?


texts:
I would like to temporarily not be able to see what I am writing (counter-intuitive, I know, but sometimes it's helpful to not be able to immediately criticize what you are writing in order to actually get some writing done).

One solution would be to turn off my display, but that is rather complicated in some situations (most laptops nowadays  --including mine-- don't dim to 0% and other solutions are OS dependent). As I use emacs for pretty much any type of writing, I would prefer an emacs solution. As I am lisp-illiterate (still, sigh), I could use some help.

I presume that making text invisible can be done by setting the facecolor to the background color; however, I don't know how to do that outside the Edit>Text properties>Display Faces menu. Furthermore, I would also like to be able to toggle the visibility of the text and I have no idea how to restore the previous color.

Any pointers are appreciated.


texts: How to access a value in a plist, given its key

texts:
I have a list of key-value pairs that is assigned to a variable.

(setq m-point '(:beg 2811 :end 3018 :op "(" :cl ")" :prefix "" :suffix ""))

How do I access the values of :beg and :end within it?

Context

I wrote a function that makes use of sp-forward-sexp and sp-backward-sexp of smartparens-mode to get the positions of a pair of custom parenthesis.

   (defun paren-position ()
      "Returns a list of positions where parenthesis has been sitting."
      (interactive)
      (let ((m-point ;; find point with matching parenthesis with `(scan-sexps)`.
         (list
          (ignore-errors (sp-backward-sexp)
          (ignore-errors (sp-forward-sexp))))))
    (flatten (remove nil m-point))))

(:beg 2811 :end 3018 :op "(" :cl ")" :prefix "" :suffix "")) is the value returned when the function is called.

This is the first time I am working with such a list with only key-value pairs (somewhat like a Python dictionary), and I don't quite know how to go about it.


texts:
I add (setq dired-listing-switches "-lXGh --group-directories-first") in my init.el

But when I go into dired mode.

  ls does not support --dired; see ‘dired-use-ls-dired’ for more details.
  insert-directory: Listing directory failed but ‘access-file’ worked

this error occurs. How can I solve this problem?
I want to sort directories first in dired mode.
My environment is macOS Sierra and emacs 25.1


texts: Search and replace TeX \over with LaTeX \frac

texts:
I have a source file that was originally coded in TeX (well, this is actually a conTeXt file). A fraction like 1/(2/x^2) is coded as {1 \over {2 \over x^2}}. I'd like to convert to LaTeX syntax, that is \frac{1}{\frac{2}{x^2}}.

Any hints? Thanks.


texts:
I'm using emacs in terminal mode. I open it up and then use c-x c-f to edit a file.

I'm using evil mode so I then use :x to save and exit. I end up leaving emacs all together. Is there something else I can do here so that I just close the file?


texts: How to properly specify defcustom default list of non-trivial data types?

texts:
How to properly write the default value for a non-trivial defcustom form in standard for something like I have below: a list of 3-element lists, with choices of the types?

The defcustom form is:  defcustom option standard doc [keyword value]...

The following defcustom works fine as long as it's default is nil.

As soon as I add a non-empty list of values in standard for the default value, Emacs *Customize* buffer UI fails (see below).

#1: My defcustom form: (with a nil value for the default, Emacs *Customize* buffer UI works fine):

(defcustom pel-key-chords nil
"..."
:group 'pel-pkg-for-key-chord
  :type '(repeat
          (choice
           (list
            :tag "expansion-keys"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (repeat
             (key-sequence :tag "key")))
           (list
            :tag "command"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (function     :tag "command        "))
           (list
            :tag "lambda"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (function     :tag "elisp code     "
                          :value (lambda () (interactive) <YOUR CODE HERE>))))))

The problem occurs when I specify a list of elements, or just one for default, as shown below:

#2: My defcustom form: (same code, but with an explicit default of one element):

(defcustom pel-key-chords
'((global   "<>"  "<>\C-b"))
"..."
...

With the default, Emacs *Customize* buffer UI fails: the INS and DEL buttons are not available and it is impossible to add or delete elements.

I read Emacs Lisp Customization Settings section and some code like the dump-jump.el code that defines some complex data with initialization. I assume I must identify some keywords in my declaration of the default, but for some reason I can't find the proper syntax for initializing the data I defined above.


texts:
I run Emacs 27.1 on my MacOS MBP and use desktop-mode.
After starting emacs (with frames re-created by the desktop restore), the frame titles are wrong and seem to remain wrong until I do something like evaluate (set-for 0) in each frame.
Anyone know why that happens?
My frame-title-format has value "%b". I don't explicitly set the frame parameter name.
GNU Emacs 27.1 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.6 (Build 19G2021))
of 2020-08-18


texts: set default fonts for Aquamacs in .emacs

texts:
I am running Aquamacs 3.3 under macOS Sierra (10.12.6).  The default fonts are way too small.  How can I do the equivalent of the following tedious procedure via code in my .emacs?

Options Menu -> Appearance -> font for LaTeX mode (or whichever mode I'm in)
The fonts window now pops up and I need to:

click Monaco 18.0 pt
click the T (for text colour) and then click the black icon (because in some modes it chooses white as the font colour by default...)
close the color window and the font window


texts: How can I rebind C-n from evil-paste-pop

texts:
I am trying to bind C-n and C-p to call next-buffer and previous-buffer. They seem to conflict with some evil-mode key bindings and I don't seem to be able to overwrite them. When I press them I get

Previous command was not evil-paste: evil-paste-pop

and

Previous command was not evil-paste: evil-paste-pop-next

for C-n and C-p respectively

In my .emacs file I have the following:

(global-unset-key (kbd "C-n"))
(global-set-key (kbd "C-n") 'next-buffer)
(global-unset-key (kbd "C-p"))
(global-set-key (kbd "C-p") 'previous-buffer)

The calls to global-unset-key were added as an attempt to resolve this issue, but to no avail.


texts:
Under most operations, when I open a file with C-x C-f Ivy pops up my narrowing list at the bottom and its great.

However, I have a current situation when I'd like to open a file on a remote host in a directory that has 60,000 files in it.  So when I C-x C-f into that directory over tramp, it takes an awfully long time until I can find the file I am looking for.  Sometimes, though I know what the file name is and I'd just like to type it and not have Ivy butt in so that I can get on with it.  How would I bet go about doing this?


texts: org-mode agenda: sort items with plain time stamp before scheduled tasks

texts:
I have an org-file which might look like the following:

* Appointments
** Meet someone important
<2018-02-15 Thu 08:00-09:00>

* Discussions
** TODO Discuss something with someone
    SCHEDULED: <2018-02-15 Thu 08:00-09:00>

Generating the agenda results in something like

8:00-9:00 Scheduled: TODO Discuss something with someone
8:00-9:00 Meet someone important

Is there a simple way to change the sorting of the agenda to sort entries with a plain time stamp before scheduled items, that is I would the agenda prefer to look like

8:00-9:00 Meet someone important
8:00-9:00 Scheduled: TODO Discuss something with someone

I had a look at the documentation for org-agenda-sorting-strategy but this looked quite complicated and I could not figure out how to achieve the desired result.


texts: void-variable dired-after-readin-hook in emacs 25

texts:
I've get emacs 25 build ppa taken from this ask ubuntu answer

and I have this functions and macro:

(defun remove-lambda-helper (list matcher)
  "function that remove lambda from a list if match the function `matcher'"
  (dolist (item list list)
    (if (and (listp item) (eq (car item) 'lambda))
        (when (funcall matcher item)
          (setq list (delete item list))))))

(defun remove-project-specifics-lambda (name hook)
  "Remove lambda from a hook that have code from `project-specifics'"
  (set hook
       (remove-lambda-helper (symbol-value hook)
                             (lambda (body)
                               (equal (cadr (cadr (caddr body))) name)))))

(defmacro project-specifics (name &rest body)
  (declare (indent 1))
  (let ((item (gensym)))
    `(progn
       (remove-project-specifics-lambda ,name 'find-file-hook)
       (remove-project-specifics-lambda ,name 'dired-after-readin-hook)
       (add-hook 'find-file-hook (lambda ()
                                   (when (string-match-p ,name (buffer-file-name))
                                     ,@body)))
       (add-hook 'dired-after-readin-hook
                 (lambda ()
                   (when (string-match-p ,name (dired-current-directory))
                     ,@body))))))

and I got error (the macro works fine in 24.5.1):

Debugger entered--Lisp error: (void-variable dired-after-readin-hook)

if I try C-h v dired-after-readin-hook, I got [no match]

was that hook removed or replaced with different one? I know that I can use directory specific file, but I want my macro to work, anybody know why this return error?


texts: Installing Emacs from source: the command `C-h v` for accessing variables doesn't work

texts:
I have installed the latest development version of Emacs on my Mac from the source by cloning the Git repository here ('Emacs source repository' under 'Anonymous clone'), and then executing make in the repo's top directory.

It didn't go smoothly, but only because I didn't have some prerequisites installed (namely, Autoconf and gnutls, and the OS X command-line tools). Once I'd installed the prerequisites (Autoconf and gnutls with Homebrew, and the OS X command-line tools by running xcode-select --install), the make script completed successfully.

However, when I open the Emacs GUI (<installation directory>/nextstep/Emacs), there's no splash screen, and instead of the usual *GNU Emacs* buffer, the *scratch* buffer opens initially.

More importantly, when I try to inspect variables by executing C-h v, the following error message appears in the echo buffer:

  Cannot open load file: No such file or directory, help-fns

Why doesn't the C-h v command work, and how can I view and set a variable's value as well as inspect the info about a variable?

I run macOS Sierra version 10.12.5 (the latest release as of today).


texts: Open link of file in org mode with its defalut application rather than within spacemacs

texts:
really new to spacemacs, I want to open a link (which is a file stored somewhere on my computer and the full path is used) inserted into org-mode file of spacemacs with the default application of such file, say excel, rather than within spacemacs. I searched up online, it seems like below is the solution:
(setq org-file-apps '("\\.xlsx\\'" . "excel %s")),but this throw out the error :

wrong type argument: listp "excel $s".

See these links for your reference and any helpful suggestion is deeply appreciated.

I'm on the latest develop branch of spacsmacs, if this is of any use.

link_1, link_2, link_3