texts: Trigger auto pairs only when selection is active

texts:
What is the easiest/simplest way to achieve the following: auto-pair parentheses (or other characters) around some text only when this text is an active region?
For example, say I do not want the character ' to trigger auto pairs for the current mode, except when I have selected some text, in which case I want the selected text to be wrapped by two ' by just pressing this key.
I currently use electric-pair-mode to pair parentheses in text-mode and in programming modes, but feel free to point out other auto-pair packages or solutions.


texts: Unusual Emacs Error scss-mode runs into 'duplicate source' error when compiling scss file

texts:
Usually with Emacs errors are syntax related. This one seems anyway a bit obscure.

On windows 10 installed sass-dart with chocolaty.

choco install sass

Note: at much earlier time installed sass-node globally, and then at the same much earlier time installed sass-node into directory with npm install sass-node -D, then removed the sass-node global installation. At time of error, there's no sass on windows path variable. This should be irrelevant.

Added scss-mode from melpa and configure as such:

(use-package scss-mode
 :commands (scss-mode scss-compile)
 :mode ("\\.scss" . scss-mode)
 :config
   (require 'scss-mode)
   ;;(setq scss-sass-command "C:/ProgramData/chocolatey/lib/sass/tools/sass.bat")
   ;;(setq exec-path (cons (expand-file-name "C:/ProgramData/chocolatey/bin/sass.exe") exec-path))
   (setq scss-compile-at-save 'nil)
   ;;(autoload 'scss-mode "scss-mode")
);end scss-mode

I get the same error using the setq scss-sass-command, the setq exec-path, switching the program paths in the same two lines (sass.bat and sass.exe), using both of them or neither of them.

"sass  'c:/Users/Username/Desktop/wd/sass-test.scss' 'c:/Users/Username/Desktop/wd/sass-test.css'
Duplicate source "'c"."

Duplicate source error. What is this error? What is the c in it? How to fix it?

I suspect Emacs runs somewhere into the option of using one or another sass executable, though I shouldn't know where it's getting the second one (the one not specified in the init file). Is it somehow accessing node-sass from a local npm package directory? That seems unlikely.

In any case, when I run sass directly from the command line, or from an Emacs wrapper on the command line, it works no problem. It just won't compile from scss-mode.

Also, and possibly relevant? Chocolatey won't upgrade dart-sass. It gives this error:

" - dart-sdk (exited 1) - dart-sdk not upgraded. An error occurred during installation:
 Updating 'dart-sdk 2.7.0' to 'dart-sdk 2.8.1' failed. Unable to find a version of 'sass' that is compatible with 'dart-sdk 2.8.1'."

Should I dump dart-sass like yesterday's news and go back to libSass via node?


texts: use-package arguments without use-package

texts:
The guide I'm following for lsp-emacs wants me to set these options:

;; Enable scala-mode and sbt-mode
(use-package scala-mode
  :mode "\\.s\\(cala\\|bt\\)$")

(use-package sbt-mode
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map))

but MELPA (and most likely mirrors of MELPA) are blocked on my school's internet, so I've been trying to use load-file with Git Submodules:

;; Enable scala-mode and sbt-mode
(load-file "~/.emacs.d/plugins/scala-mode/scala-mode.el"
  :mode "\\.s\\(cala\\|bt\\)$")

(load-file "~/.emacs.d/plugins/sbt-mode/sbt-mode.el"
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map))

However, the :colon commands aren't allowed as options on load-file. How can I get these options to work?


texts: How to configure org-mode to respect system-specific default applications for external links?

texts:
In org-mode I can define external links for example as

[[file+sys:path/to/document.pdf]]

The file document.pdf is then opened with an external pdf viewer. The org-mode documentation claims that this command "open[s] via OS, like double-click".

There is, however, a difference to "double-click", as I find that the system-specific default applications (for documents, websites, videos, etc.) are not respected in my setup; On Ubuntu 12.04 the default application for webpages was set to Firefox and only through org-mode local .html files are still openend with Chromium.

How do I configure org-mode to respect my default application settings?


texts: What does `setq-local` do, and when should I use it?

texts:
I'm not quite clear on all the variations of buffer-local variables, even
after reading all the doc and a bunch of postings here on SX.

Here's a summary of my understandings:

(defvar foo ..) declares a dynamic variable for the file. But the
variable is (1) not known to other files unless they include a defvar
statement as well, and (2) the variable is global in scope, not buffer
local.

(make-variable-buffer-local foo) after the defvar above tells the
compiler and everyone else that the variable foo is to be treated as
buffer-local everywhere it is set, when it is set. So this pattern is
good style for declaring a buffer-local variable, putting both statements
back-to-back in the file.

(defvar xxx ...)                    ;declare xxx with global scope
(make-variable-buffer-local 'xxx)   ;but now make it buffer-local everywhere

For convenience, the (defvar-local xxx ...) form can be used as one
line, in place of the two lines above:

(defvar-local xxx ...)       ;make xxx buffer local everywhere

Once declared as above, the variable xxx can be used like any other
variable in setq statements.

If I just want to have a single instance of a buffer-local variable that
is already a global dynamic variable, I would use the following
declarations. The first one declares the global-scope dynamic variable,
and the second statement makes just one instance of a buffer-local
version of that variable, in the current buffer:

(defvar xxx ...)             ;declare xxx with global scope
(make-local-variable 'xxx)   ;make xxx local in this buffer only

Now for my explict questions (all the above were implicit questions on
whether my understanding is correct).

When setting the value of variables, I can use setq or
setq-local. When should setq-local be used? Why?

What happens if I use setq-local on buffer-local vars, or
non-buffer-local vars?

Is setq-local required for a defvar-local declared variable?

Will setq-local on a normal defvar declared variable turn it into a
buffer-local variable? (In other words, is setq-local somehow the
equivalent of a (make-variable-local xxx) declaration?


texts: Emacs and EXWM window manager. Switch between applications and emacs buffer

texts:
I'm trying to use Emacs as my main window manager, by using EXWM:

  https://github.com/ch11ng/exwm

.

Installation works fine. However, my default Emacs key binding to move between splits is: Shift + Arrow keys.  This doesnt seem to work if you have say Firefox on the left split, and say an Emac buffers like scratch buffer on the right (a vertical split).

I can do Shift+ Left and it focuses the cursor on the Firefox instance.  However, I cant seem to move from Firefox back to scratch buffer, i.e. doing Shift + Right doesnt work.

Please let me know how to get this to work.  I can just use the mouse to click the buffer but I'd rather use the keyboard.


texts: Controlling window locations for files visited by Dired

texts:
Very often I need to open a file in dired in other window and for that dired-find-file-other-window comes handy, but sometimes I want to open file in specific split - vertical or horizontal. So if I have:
two windows (with dired on the left)

  |-----------+-----------|
  | -window1- | -window2- |
  | file1     |           |
  | file1     |           |
  | file3     |           |

and want to explicitly tell dired to open file:

either by creating a vertical split in window1:

  |-----------+-----------|
  | -window1- | -window2- |
  | file1     |           |
  |-----------+           |
  | (content) |           |

or in window2 (which is usually a default behavior of dired-find-file-other-window:

  |-----------+-----------|
  | -window1- | (content) |
  | file1     |           |
  | file1     |           |
  | file3     |           |

or below window2 (by creating vertical split in window2):

  |-----------+-----------|
  | -window1- | -window2- |
  | file1     |           |
  | file1     |           |
  | file3     +-----------|
  |           | (content) |

or by creating horizontal split (adding new window to the right of window2):

  |-----------+-----------+-----------|
  | -window1- | -window2- | (content) |
  | file1     |           |           |
  | file1     |           |           |
  | file3     |           |           |

Is there a package for doing something like that? If not, can someone help me writing a function/functions?


texts:
Is that possible to Emacs to respect .gitattributes and .hgeol?

I am again on Windows with Cygwin emacs-w32 and would like if Emacs honor project specific CR/LF settings for new files...


texts: I am interested to know more about the use of the phrase "pop" in relationship to the mark in Emacs. The command pop-global-mark, as I understand it, jumps to the buffer and position of the latest entry in the global ring and also rotates the ring. But why the use of the word "pop" and what exactly is popped?


texts: Disabling the "Auto-saving...done" message

texts:
I want my documents to be auto-saved, but I don't want to be interrupted with the message "Auto-saving...done" every few minutes.

Is there a way to just disable this message, but not the auto-saving functionality?

I have tried the following without success:
https://stackoverflow.com/questions/22511847/how-to-disable-auto-save-message


texts: org-mode ignoring category filter on export

texts:
I'm trying to create a "calendar only" view of my org-mode agenda -- only headlines that have a "cal" category. The org-agenda-custom-commands below (the first block) works brilliantly for viewing within emacs, but the filter doesn't work when I C-a a e to export. That is, calendar.txt ends up with headlines from all categories, instead of only "cal" categories.

Is this a bug, or am I misunderstanding something?

;; custom agenda views
(setq org-agenda-custom-commands

      ;; bug?: exporting to calendar ignores my category filter, but
      ;; it works when I view in emacs
      '(("c" "Calendar only" agenda ""
         ((org-agenda-category-filter-preset '("+cal"))
          (org-agenda-span 'week)
          (org-agenda-use-time-grid nil))
         ("~/Dropbox/wiki/calendar.txt"))

        ;; the default block view that comes with org mode
        ("n" "Agenda and all TODO's"
         ((agenda "" nil)
          (alltodo "" nil))
         nil
         ("~/Dropbox/wiki/agenda.txt"))))


texts: Building Command to Append Selected Text to End of File (w/Tab Completion)

texts:
Problem: I'm trying to write a command that takes the selected text and appends it the end of a file of my choice.

There also needs to be a tab completion (or autocompletion) element to the command, in the sense that the command should be able to autocomplete to files that are nested somewhere within the directory /tab/completion/directory.

Example: Suppose there is a file /tab/completion/directory/nested/file.md, and I select text in my buffer and run M-x append-to-file, then I should be able to M-x append-to-file file.md<TAB> for it to autocomplete to M-x /tab/completion/directory/nested/file.md. After running this command, the selected text should be sent to end of the file.


texts: How do I set the directory-abbrev-alist values?

texts:
I'd like to customize this value - it's briefly mentioned in the manual.

How can this be done?


texts: Issue with org-mode export to pdf via LaTeX

texts:
Whenever I export my org-mode (version 8.2.10) file to pdf via LaTeX, it gives me:

Page 1 with only content 2015/01/01Old fixltx2e package 0000/00/00Old fixltx2e package and the rest part is blank.

Page 2 onwards normal expected content but with raster fonts.

Edit:

My .org file header:

#+LaTeX_CLASS: article
#+LaTeX_CLASS_OPTIONS: [12pt]
#+LaTeX_CLASS_OPTIONS: [a4paper]
#+LATEX_HEADER: \usepackage[hyperref,x11names]{xcolor}
#+LATEX_HEADER: \usepackage[colorlinks=true,urlcolor=SteelBlue4,linkcolor=Firebrick4]{hyperref}
#+LaTeX_HEADER: \usepackage[T1]{fontenc}
#+LaTeX_HEADER: \usepackage{mathpazo}
#+LaTeX_HEADER: \linespread{1.05}
#+LaTeX_HEADER: \usepackage[scaled]{helvet}
#+LaTeX_HEADER: \usepackage{courier}
#+OPTIONS: H:2 email:t |:t
#+TITLE: To-do List
#+TODO: TODO(t@/!) URGENT(u) | DONE

I checked the .tex file auto-generated before the pdf generation. However, the corresponding .tex file generated from my .org file has the package \usepackage{fixltx2e} though the .org file doesn't have any such package.

Header of the autogenerated .tex from my .org file:

% Created 2018-03-29 Thu 22:24
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage[hyperref,x11names]{xcolor}
\usepackage[colorlinks=true,urlcolor=SteelBlue4,linkcolor=Firebrick4]{hyperref}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\linespread{1.05}
\usepackage[scaled]{helvet}
\usepackage{courier}
\author{xyz@abc.com}
\date{\today}
\title{To-do List}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 25.2.1 (Org mode 8.2.10)}}

There appears some error with fixltx2e.sty file.

Below is the screenshot of the first page of the org exported pdf as generated.

Zoomed view of the aforesaid scrrenshot.


texts: Is there a way to use query-replace from grep/ack/ag output modes?

texts:
I'm aware of find-grep-dired, marking the corresponding files and then pressing Q to run dired-do-query-replace-regexp on the marked files. Unfortunately that requires restarting the grep and no longer using git-grep, ack, or ag and switching to use find-grep which has a different syntax for searching.

I'm also aware of multi-occur and occur-edit-mode, but that requires restarting the search using occur. Finally, ag-dired appears to match on the filename, not on the contents of the file.

My current approach is to generate grep output, and then run a macro that starts in the grep buffer, and visits each match and changes it. I would prefer to use query-replace directly over the set of matches found.

What I would like to do is to either quickly build a dired buffer from existing grep output so that I can mark the appropriate files and call query-regexp on them, or transform grep output into a list of buffers for multi-occur so that I can use occur-edit-mode to edit it in place and run query-replace on that buffer.

Does this functionality exist, or is there another workflow that solves this problem?


texts: Add an article preview to the gnus-summary-line-format

texts:
I am using gnus to read my email and the current setting for the gnus-summary-line-format in my .gnus.el is

(gnus-summary-line-format
  "%U%~(pad-left 5)R: %~(max-right 25)D | %~(pad-right 25)~(max-right 25)a | %~(max-right 50)s \n")

Is there a way to modify this setting in order to show a short preview of each article in the summary buffer (say the first line, or the first x characters of the corresponding email) ?

This question is raised in EmacsWiki but I could not find answer.

Thanks for your help


texts: How to make list-packages Help for dependency package show the dependee packages?

texts:
I use use-package to require the boxquote package into my GNU Emacs 26.3 running on Ubuntu 19.10, like this:

 (use-package boxquote
   :ensure t)

In the list-packages buffer, I see the boxquote package:

boxquote           20170802.1117 dependency            Quote text with a semi-box.

Typing ? on that line, reveals:

boxquote is a dependency package.

     Status: Installed in ‘boxquote-20170802.1117/’ (unsigned).
    Version: 20170802.1117
     Commit: 7e47e0e2853bc1215739b2e28f260e9eed93b2c5
    Summary: Quote text with a semi-box.
   Requires: cl-lib-0.5
   Homepage: https://github.com/davep/boxquote.el
   Keywords: quoting
Other versions: 20170802.1117 (melpa).

If Emacs knows it is a "dependency package", shouldn't it show Required By: or similar? I say that because another "dependency package", async does show this line in its Help buffer:

async              20200113.1745 dependency            Asynchronous processing in Emacs
...
async is a dependency package.

     Status: Installed in ‘async-20200113.1745/’ (unsigned).
    Version: 20200113.1745
    Summary: Asynchronous processing in Emacs
   Requires: emacs-24.3
Required by: magit-popup-2.13.0, with-editor-20200217.1015, magit-20200318.1224, helm-core-20200306.1417, helm-20200325.757
   Homepage: https://github.com/jwiegley/emacs-async
   Keywords: async
Other versions: 1.9.3 (installed), 20200113.1745 (melpa), 1.9.3 (gnu).

An answer to What does dependency mean in the Status field of a package shown in list-packages says:

  Packages which were explicitly installed by the user are identified as such by adding them to package-selected-packages.

Viewing the current value of package-selected-packages shows:

package-selected-packages is a variable defined in ‘package.el’.
Its value is
(org git-timemachine htmlize elpy ggtags graphql helm helm-pydoc magit magit-popup ob-async org-plus-contrib use-package)
Original value was nil

So I'm puzzled: I am using use-package so it is kind of "selected" by me, no?

Also, further searching turns up a comment to an answer to Confusing ELPA types which says:

  I wouldn't expect the 'required' package to list all the packages that require it - how would you know who else might require your code? More likely Emacs auto-generates the 'required-by' attribute during installation. If it's not filled in, perhaps something went (mildly) wrong during installation. – Tyler Jul 16 '18

"how would you know who else might require your code" is exactly what I'm after, so that I can trace it back ultimately to a require or a use-package call in my own setup, to determine if it is safe to remove. Is there something wrong with my use of use-package?


texts: Org-mode only export LaTex Source Blocks

texts:
I'm looking to use org-mode to typeset homework for a math class I'm taking and was wondering if there is a way to export only certain LaTex blocks to the final PDF using org-babel.  As an example consider

** TODO [#A] Question 1
   DEADLINE: <2017-01-17 Tue>
   Notes about the problem and links to resources would go here.
   #+BEGIN_SRC latex
     \begin{exercise}{1}
       Prove the theorem
     \end{exercise}
     \begin{proof}
       Let $x \in A$ blah blah.....
     \end{proof}
   #+END_SRC

When exporting to PDF I would only want the LaTex code to show up in the PDF but not the TODO heading or any of the other notes and links that might be below it.  Is there a way to do this?


texts: Why does a constant in `let` change with repeated calls?

texts:
Say we have such a foo function:

(defun foo (e)
  (let ((lst '(a b c)))
    (delq e lst)))

Then we use it in following way (sequentially evaluating one by one):

(foo 'c) ; => (a b)
(foo 'b) ; => (a)
(foo 'a) ; => nil
(foo 'b) ; => (a)

What happened here?

If I define another bar function:

(defun bar (e)
  (let ((lst (list 'a 'b 'c)))
    (delq e lst)))

Then use it in the same way:

(bar 'c) ; => (a b)
(bar 'b) ; => (a c)
(bar 'a) ; => (b c)
(bar 'b) ; => (a c)

The results here seem reasonable to me.

So question is, why the constant in the let form of the foo function behave in this way? Is it intended?


texts: dired-do-copy in tramp does not go to local when `\ C-j` is pressed. File path stays in the same directory

texts:
I am using dired-do-copy to copy a file from remote using tramp to local.
When Copy file to path is promted. I used / C-j to go to local path but the path stays in the same directory , does not go to local root from remote.

I have also tried M-x copy-file , M-x gnus-copy-file and I have having the same issue as above.

Emacs version - 26.2
Local Os - MacOs
Remote server OS(Tramp) - RHEL
Swiper version - 20190708.1110

Steps to replicate -

Login to a remote using tramp
Open a directory in remote using dired.
Mark a file to copy, and run M-x dired-do-copy.
Swiper/IVY will prompt the path.
Type '/ C-j' to go to local.
The path stays the same.
Same thing happens to M-x copy-file in tramp mode too.

Trying to implement this functionality - https://superuser.com/questions/445564/how-do-you-copy-files-from-a-remote-server-to-a-local-folder-in-emacs-using-dire/445568

Also is there a way to disable counsel-find-file when dired-do-copy is triggered.


texts: How do you do "git checkout -- .emacs" using magit?

texts:
When a file (like .emacs for example) is modified in a Git repository, if I want to git pull git refuses to do so because I have a modified file. Git proposes to remove the modification by doing

git checkout -- .emacs

But how do you do that using Magit ? I have seen that -- is the equivalent of --ignore-skip-worktree-bits but I don't see this option in Magit.


texts: Mark files whose name starts by a given prefix

texts:
I'm using Dired+. In folder1 I have 200 files.
30 files start with 15_02_xxx, 46 files start with 16_02_xxx and the rest have other names.

I want to copy from folder folder1 to folder2 only files whose names start with 15_02_xxx or  16_02_xxx. So the total number of marked files must be 76.
So how in Dired mode I can select only the desire files?

Emacs 26.1, Windows 10, Dired+


texts: Is there a function that opens a file chooser minibuffer and returns an absolute file name?

texts: I want to write a function in my init.el file that basically opens a file-browser minibuffer for the user (the standard one or the one from helm) and returns an absolute file name to be used in another function.


texts: Tramp: how to add (-A) agent forwarding to ssh connections?

texts:
I'm using Magit over Tramp and my git push commands fail because tramp doesn't forward my ssh-agent to the remote machine.

In pseudo code, it looks like I need to do the following:

tramp-methods["ssh"][tramp-login-args].prepend( ("-A") )

How do I do this without copy/pasting the entire tramp-methods variable into my emacs init file? Or is there a better way to do this?


texts:
I'm using emacs to run ansi-term with an ssh'ed tmux inside. I can scroll using my prefix C-b + [ as per this thread, but I would like to be able to scroll with the mouse immediately.

This seems to work if I'm doing it in a terminal outside of emacs, so I'm wondering what steps are necessary when doing it within emacs.


texts:
I am in shell-mode with bash-completion enabled. When I attempt tab completion, Emacs creates a new window to display completions.

For example, if I am in a directory with subdirectories foo and foobar, and I type cd foo TAB, Emacs will open a new buffer with the following contents:

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
foo/
foobar/

If I C-x o into the other window and select a completion, then the window disappears. However, that takes a few keystrokes, so sometimes I end up instinctively completing the path myself. If I do that, the window sticks around.

How can I improve this workflow so that my shell stops generating extra windows? I didn't want to make this an XY problem, but I can think of a few ways. One idea would be to hide the window if I keep typing. Something better would be to hook the completion results into ido.


texts:
The debug-on-message variable tells Emacs to start the debugger when a matching message is displayed. How can I get Emacs to invoke my own function when a matching message is displayed?

My motivation in this case is to build a contingency engine for common errors. Not all of these are well-handled locally through advice or unwind-protect, so I would like to use the echo area (or equivalently the *Messages* buffer) as my input.

Example usage: (do-on-message "Foo error" 'handle-foo)


texts: How to define a "composite type" with the "group" constructor?

texts:
I am trying to define a composite type using the "group" compositor (see Elisp Manual, section "Composite Types"). Previously, I managed to define a composite type with the "list" constructor.

The Elisp manual tells that these constructors ("group" and "list") are similar. I get a weird result in the "Customize interface" and an error message displayed in the echo area.

Operate on all settings in this buffer:
[ Revert... ] [ Apply ] [ Apply and Save ]

Hide

Sample code

(defcustom group '(1 2 3)
    "here, give a description of the user option."
    :type '(group integer integer integer))

I noticed the message "custom-variable-value-create: Bad format" in the "Messages" buffer.

The manual should be clarified. Someone had the same issue one decade ago: "No doc for `group' in custom :type".

.


texts: Is there a way to spread a list like in Typescript or Golang?

texts:
I have a variable with some common values between dap-mode debug templates and I want to use that variable along with other cons elements for :environment-variable in languages like Golang or Typescript you would do something like this:
variable = [1, 2, 3]
another_variable = [...variable, 4, 5, 6]

then another_variable will carry the value of [1, 2, 3, 4, 5, 6]
How can I do this in Emacs Lisp?
EDIT: I know how you can evaluate something inside a list, this is using the backquote, my problem was that I didn't know how Elisp processes lists in a fashion that keep the result plain because, for instance in Python, you can end with something like [1, [2, 3, 4]] if x is [1] and you do x.append([2, 3, 4]); I didn't know that ,@ was a thing and that neither append keeps a plain list.


texts: After upgrading AUCTeX, (La)TeX mode is unusable (invalid-function TeX-auto-add-type)

texts:
I installed AUCTeX through the package interface. This pulled version 11.89 from ELPA. Before that, I was running a version of AUCTeX provided by my operating system (Ubuntu 12.04), which is 11.87. After restarting Emacs to ensure I was using the new version, switching to (La)TeX mode fails with the error

File mode specification error: (invalid-function TeX-auto-add-type)

I have no reference to TeX-auto-add-type in my init file, so what's going on?


texts:
I'm using the answer from https://stackoverflow.com/questions/13559061/emacs-how-to-keep-the-indentation-level-of-a-very-long-wrapped-line but can't make it do exactly what I want

If I have this long line of code:

if some_condition:
then
    some very long long long long long long long line
fi

With:

(add-hook 'visual-line-mode-hook 'adaptive-wrap-prefix-mode)
(visual-line-mode t)

it turns to:

if some_condition:
then
    some very long long long long long
    long long line
fi

but I would like this to turn to

if some_condition:
then
    some very long long long long long
    ... long long line
fi

This doesn't work:

(setq wrap-prefix "... ")


texts: Magit log, limit to files, and completion can be very slow for large repositories

texts: Doing magit-status, magit-log-popup, and =f to limit to files will try to help by building up a list of paths for completion.  However, with moderately large repositories, which have a path like ssh://..., Emacs may lock up for something like five minutes (the watch is displayed and no interaction with Emacs is possible).  Setting magit-completing-read-function to ignore does not help.  Is there a workaround to avoid this delay?


texts: Org mode evaluating propertized string removes properties

texts:
See the following code block:

#+BEGIN_SRC emacs-lisp
(setq s #("abc" 0 3 (face (:foreground "red"))))
(pp s)
#+END_SRC

#+RESULTS:
: #("abc" 0 3
:   (face
:    (:foreground "red")))

which is as expected, but literally just by evaluating,

#+BEGIN_SRC emacs-lisp
s
#+END_SRC

#+RESULTS:
: abc

#+BEGIN_SRC emacs-lisp
(pp s) ;; how did s change?
#+END_SRC

#+RESULTS:
: "abc"

I noticed this when calling C-c C-c on

#+BEGIN_SRC emacs-lisp
org-mode-line-string
#+END_SRC

actually removes fontification on the mode line of the current clocking task.

This does not happen for C-x C-e(eval-last-sexp).

I'm using Org 9.1.9 on Emacs 26.3.


texts:
C-c . could insert the timestamp of the current date and C-u C-c . insert the current datetime.

I find it very difficult to insert an arbitrary datetime.

Operations over Calendar are invalid since the focus stay on the mini-buffer.

A work-around solution to insert  <2019-08-09 Fri>

M-x calendar to select year 2019, month of August, Day of 09
C-x o switch to other buffer from the calendar
C-c < (org-date-from-calendar)

Is there a handy way to insert a specified timestamp? or how could scroll the Calendar after strike C-u C-c .?


texts: Gnus: Moving multiple articles to a single group

texts:
My question is similar to How to move multiple articles from one Gnus group to another?. However the answer given there didn't work for me.

Suppose I want to move multiple articles in a summary region to another group (I am accessing emails over IMAP), I mark all the articles in a region with M P r to get a # mark. Now I do M-& B m to move the process marked articles and specify the target group.

Unfortunately, Gnus is asking me the target group for each and every article which is annoying. What am I doing wrong?

EDIT: Looks like I was unnecessarily pressing M-& (i.e. M-S-&) before B m as specified in the below pasted last paragraph of https://www.gnu.org/software/emacs/manual/html_node/gnus/Process_002fPrefix.html#Process_002fPrefix

Many commands do not use the process/prefix convention. All commands that do explicitly say so in this manual. To apply the process/prefix convention to commands that do not use it, you can use the M-& command. For instance, to mark all the articles in the group as expirable, you could say M P b M-& E.

While commands like expire article (E) will need the above M-& prefix, the commands like B m (gnus-summary-move-article) will honor process marks and will move all marked articles to the target buffer.


texts: Speed up org-map-entries when matching by property

texts:
Question: Why is org-map-entries property matching so slow, and what can I do to speed it up?

Background: I have a relatively simple use for org-map-entries: grab the effort (in integer minutes) from all org agenda entries with tag goal and a given priority (e.g. B).

(org-map-entries
   #'hw-org-get-effort-in-minutes
   "goal+PRIORITY=\"B\""
   'agenda)

This is terribly slow, taking over a minute for my ~12k line agenda file.

However, if I remove the PRIORITY from the filter so any goals tagged item is selected, it completes almost instantly.

I can also set filters like goal/DONE and they complete very quickly, but if I do something like goals+EFFORT>0 we are back to taking over a minute. It seems properties in general are very slow to match.

I found a cheat workaround: I can match properties inside the the mapped function very quickly using org-entry-get. When I do this, execution is less than a second. This seems silly, hopefully there is a better way, but at least it works!

Already tried: Since (benchmark 1000 (hw-org-effort-to-minutes "1:20")) returns "Elapsed time: 0.000019s", I don't think my function contributes much.

According to profiler, ~40% of CPU time is used by cond, with ~29% coming from element parsing (org-element--current-element). The next two largest contributions overall are 14% and 13%, so the 40% of cond seems to be the bulk of the problem. Not sure why element parsing would be done more often with property matchers, unless the difference comes from parsing only header  (tags, TODO) vs. header + body (properties).


texts: Swap default behavior of command with C-u behavior

texts:
Many Emacs commands alter their behavior when called with one or more C-u prefixes. In some cases the default behavior of a command is less useful to me than the behavior I get when prefixing it with C-u. At the same time, I do not want to get rid of the default behavior completely.

To give a concrete example, the quit-window command (bound to q in help-mode) quits the current window and buries the buffer displayed in it by default. When called with C-u it kills the buffer instead. I would like the command to kill the buffer by default and bury it when called with a C-u prefix.

Q: How can I tell Emacs to make a command behave as if it was called with a C-u prefix by default while moving the default behavior to the C-u prefix?

I know that I could address this by redefining the original command or wrapping it in a custom command that passes prefix args according to my preferences. But I'd rather do something like this:

(swap-args 'quit-window)


texts: Org babel google translate functions not defined

texts:
trying to run the google-translate package in org mode, I have the following error in the package :

ob-translate.el:84:1:Warning: the following functions are not known to be defined:
    google-translate-insert-nulls, google-translate-http-response-body,
    google-translate-format-request-url

And these are the functions run by org babel when evaluating the source code.


texts: Why is slime working in emacs but not in the minimal set-up?

texts:
I am quite new to Emacs. Hence, I have been using the minimal set-up version. However, slime seems to work only on the full version.
If I do on my Ubuntu 20.04 terminal the following:
emacs

And then, inside emacs:
M-x slime

I have slime working perfectly. However, if I use the minimal setup version with:
emacs -nw -Q

After typing M-x slime I get the following error version:
M-x slime (no match)

Is there something I could to run the Smile REPL inside emacs minimal set-up?


texts: Use all eight weights of IBM Plex fonts in emacs (including "Text")

texts:
I was inspired by Paul Ford to use IBMs font Plex for my emacs config. One of the strengths of IBM Plex is that all the four families  each have eight weights.

The families: Mono, Sans, Sans Condensed, Serif

The weights:  Thin, Extra Light, Light, Regular, Text, Medium, SemiBold, Bold

But I encounter three problems:

setting :weight text (in the customize-area)

'(variable-pitch ((t (:family "IBM Plex Sans" :height 152 :weight text))))
  Error Message:
Invalid face weight: text

medium and regular seem to be interpreted as the same font weight. At least nothing changes if I use :weight regular or :weight medium.
The font on regular looks different (heavier) in emacs than what I see on the "Typetester" (white button) on the font's website.

Is there a way to enable all the eight font weights for use in emacs?

I am fairly new to emacs.


texts: Configure company completion to allow typing non-matching characters

texts:
I am a newbie to emacs and know nothing about lisp.
I just want to config some features for autocompletion.

Here is how I config company-mode now:

(eval-after-load 'company
  '(add-to-list
    'company-backends '(company-irony-c-headers company-irony)))
(eval-after-load 'company
  '(add-to-list 'company-backends 'company-irony))
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(global-set-key "\t" 'company-complete-common)

I want the auto complete pop up window to be closed when I type any character. For example, I type "ab" and I hit , the auto complete window pop up. I was unable to type any character that is not in the auto complete list. So, I want when I type "c", the pop-up window close and "c" should be inputted.


texts: How to move point to new window, within a function?

texts:
I'm trying to write a simple function to divide the Emacs frame into four quadrants.  Once I get the splitting to work, each window will have Dired for a different directory.

The splitting isn't giving the results I want, because I can't move point to the window I want to split.

Here's what I have for the window splitting:

(defun split-into-quadrants () "Manipulate windows" (interactive)
       (delete-other-windows)
       (split-window-vertically)
       (split-window-horizontally)
       (next-window)
       (next-window)
       (split-window-horizontally)
       (next-window)
       (next-window))

The splits work fine. next-window has no effect.

If I issue these commands interactively, Emacs does exactly what I want.  But when I execute the function, point remains in the first window and I end up with three windows in the top half of the frame and one in the bottom half.  What am I missing?


texts: Maxima won't start, but works in org-mode

texts:
This is very odd, but I've got latest greatest everything -- 26.1; org-mode  9.1.14 9.1.14-9-g131531-elpaplus; maxima-5.42.1 (installed from source) -- and have this in my .emacs:

(add-to-list 'load-path ".../Downloads/maxima-5.42.1/src/")
(setq org-babel-maxima-command ".../Downloads/maxima-5.42.1/src/maxima")
(autoload 'maxima-mode "maxima" "Maxima mode" t)
(autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t)
(autoload 'maxima "maxima" "Maxima interaction" t)
(autoload 'imath-mode "imath" "Imath mode for math formula input" t)
(setq imaxima-use-maxima-mode-flag t)
(add-to-list 'auto-mode-alist '("\\.ma[cx]" . maxima-mode))

And this seems fine for working with the examples in this. However, when I just try to run Maxima by itself (M-x maxima-mode, imaxima, maxima), I get errors:

for maxima or maxima-mode:

Cannot open load file: No such file or directory, maxima-font-lock

for imaxima:

 Cannot open load file: No such file or directory, imaxima-autoconf-variables

I have imath.el, maxima.el, and imaxima.el from the Maxima distribution in  ~/.emacs.d/maxima with

add-to-list 'load-path "~/.emacs.d/maxima/")

early in my .emacs. What am I missing here? Why does org-mode see Maxima and work, while a regular session doesn't?


texts: Export a particular org heading with elisp?

texts:
I'd like to specify a heading (using either link or agenda syntax) and export just that heading as a file, using elisp.

I'm not trying to do this - since this specifies the file to export to in the file itself: How to export top-level headings of org-mode buffer to separate files?

I think it might involve specific input to org-export-as? (a function in ox.el)


texts: Rust Racer autocomplete problem in Cygwin

texts:
I'm trying to set up racer mode for Rust language autocomletion, but when press 'tab' key got messages like this:

Company: An error occurred in auto-begin
Company: backend company-capf error "/cygdrive/d/Soft/Cygwin64/home/racer/target/release/racer exited with status 1" with args (candidates B)
Company: An error occurred in auto-begin
Company: backend company-capf error "/cygdrive/d/Soft/Cygwin64/home/racer/target/release/racer exited with status 1" with args (candidates B)
Company: An error occurred in auto-begin
Company: backend company-capf error "/cygdrive/d/Soft/Cygwin64/home/racer/target/release/racer exited with status 1" with args (candidates B)

Here is my .emacs:
(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(setq company-tooltip-align-annotations t)

(setq racer-cmd "/cygdrive/d/Soft/Cygwin64/home/racer/target/release/racer")
(setq racer-rust-src-path "/home/rust/src/")

(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)

(add-hook 'racer-mode-hook #'company-mode)

(global-set-key (kbd "TAB") #'company-indent-or-complete-common) ;

(defun rust-save-compile-and-run ()
  (interactive)
  (save-buffer)

  (if (locate-dominating-file (buffer-file-name) "Cargo.toml")

      (compile "cargo run")

    (compile
     (format "rustc %s & %s"
         (buffer-file-name)
         (file-name-sans-extension (buffer-file-name))))))

(add-hook 'rust-mode-hook
      (lambda ()
        (define-key rust-mode-map (kbd "<f5>") 'rust-save-compile-and-run)))

Any help would be appreciated.
UPDATE:
So, when i try to call racer from emacs shell, i got following message:
racer can't find the directory pointed to by the RUST_SRC_PATH variable "/cygdrive/c/src/rust/tasks/src/C:\Program Files\Rust stable 1.5\rustc-1.5.0\src". Try using an absolute fully qualified path and make sure it points to the src directory of a rust checkout - e.g. "/home/foouser/src/rust/src".

But i don't know how to fix this. By the way, i'm working in Cygwin.
Now, i got following error:
eldoc error: (error /cygdrive/d/Soft/Cygwin64/home/racer/target/release/racer exited with status 1)


texts: ibuffer - Cursor on buffer which it was called from

texts:
Ibuffer is great, I  use it with filter groups which work great. I call Ibuffer using by a keypress, the problem is that the cursor is always on the first buffer in the first category. What I need is that it is on the buffername which it was called from. I mean if I'm in notes.org and call ibuffer the cursor should be on notes.org.

Any variables that can help me out there? I couldn't find any. I assume elisp is needed to solve it but I have no ability to code.


texts: How can I customize the colors used for reStructuredText?

texts:
Somehow I got into the situation where my section headings in ReST mode are rendered in one shade of gray for the foreground and another, nearly identical shade of gray for the background.  This makes the section headings almost completely unreadable to me.

So, I am a simple user with a rather simple question: How can I customize the colors for ReST mode to fix this?

Here is the output of my version command:

GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.21) of 2013-10-25 on allspice, modified by Debian


texts: Problem with the behavior of org-fontify-done-headline

texts:
I want entries with the DONE status to be greyed out, so in my init file I have

(setq org-fontify-done-headline t)

and I have added

 '(org-headline-done
   ((((class color) (min-colors 16) (background dark))
     (:foreground "dim gray"))))

to custom-set-faces.

It works very well in the org file itself. However, when I display an entry in a custom agenda view (with org-agenda-custom-commands) with another status (say, TODO), and that there are checkboxes below the headline of the entry in question, the entry will be greyed out if at least one of the checkboxes is left unchecked, but will not be greyed out if all the checkboxes are checked.

I have no idea where to search to find a fix for this weird behavior.


texts: How to split mail according to both "from" and "subject"?

texts:
Hope to try to filter some mail from "foo@example.com" and the subject contains "sw-report".

I tried to put this configure to my init.el:

   (setq nnmail-split-methods 'nnmail-split-fancy
         nnmail-split-fancy
         '(any "sw-report"
               (from "foo@example.com" "nnmaildir+COMPANY:INBOX.SWREPORT")))

But it doesn't work. Nothing is filtered.

My inbox is locate at nnmaildir+COMPANY:INBOX.


texts: Preventing emacsclient -c from bringing both Emacs frames to the front

texts:
Environment Cygwin, emacs-w32 variant.

Use case Setting up my editor for git commits from the terminal.

Problem
When I do a git commit from a terminal, I have it setup to do

emacsclient -c

I get a new frame as expected, and Emacs brings it to the front and focuses it correctly. However, it also brings to the front (but without focusing), my main Emacs window. So now I have two Emacs frames on top, indeed I can see the buffer I am editing in both of them.

By main Emacs window, I mean the one that I usually start when I login. This is annoying, because I often minimize that window while I work on other things.

I suspect it may be caused because I call server-start in my .emacs file, but I don't know a way to work around it.

Aim
I really just want to popup the new frame, leaving the old frame completely alone, then I will close the new frame after typing in my git commit message. It's sort of a "throw-away, quick edit", completely focused on the job in hand.


texts: Emacs can't save history of recent visited files opened in current session before shutdown

texts:
I have a problem with emacs started as daemon using Systemd.

Every shutdown/reboot if I don't stop emacs daemon service manually, the history of recent opened files in current session is lost.
I think this is because of the Systemd that can't properly kill Emacs when in a shutdown state.

What can I do to solve this problem?

My recentf config in init.el:

(use-package recentf
    :config (progn (setq recentf-auto-cleanup 'never
                         recentf-max-menu-items 50
                         recentf-max-saved-items 400
                         recentf-save-file
                         (expand-file-name "temp/.recentf" user-emacs-directory))
                   (recentf-mode t)))

Systemd emacs service config:

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"

Restart=always
User=%i
#WorkingDirectory=%h

[Install]
WantedBy=multi-user.target


texts: Is there a way to avoid appending AUCTeX variables in the file when working with multiple files?

texts:
When editing multiple files, AucTeX keeps track of the master file by appending the following to each file:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../document"
%%% End:

I'm editing a document with multiple colleagues and I don't want to add this to their files when editing them.

Is there a way to set an AucTeX variable pointing to the path of the master file, and whenever I hit C-c C-c, it will look for that file?

One option is to hit M-: and type (setq-default TeX-master "../document"). Is there a better way than that?


texts: How to use OSX command line GUI emacs as git $EDITOR

texts:
I have a script to launch OSX GUI emacs from command line at:

/usr/local/bin/emacs

The script looks like:

#!/bin/sh
$(/Applications/Emacs.app/Contents/MacOS/Emacs --chdir $PWD "$@") &

I have configured a bash $EDITOR environment variable:

export EDITOR=/usr/local/bin/emacs

I want git to open the GUI emacs for commit messages and rebase messages

If I try to commit:

evs-MBP:skeletal-animation-system kev$ echo "cool" >> fake.js
Kevs-MBP:skeletal-animation-system kev$ git add fake.js
Kevs-MBP:skeletal-animation-system kev$ git commit
Aborting commit due to empty commit message.

This will launch the GUI prepopulated with the correct commit prompt however I believe because the command runs in the emacs command runs in the background git thinks it immediately quits.

Similiar undesired behavior happens with a rebase.

Kevs-MBP:skeletal-animation-system kev$ git rebase -i origin/master
Successfully rebased and updated refs/heads/rebase-test.

The rebase is automatically completed. I'm assuming again because the processes detaches and git thinks it completed.

I'm looking for a way to use GUI emacs with the git command line tool.


texts: Inspect element in Firefox from within Emacs

texts:
In Firefox, when I right-click anywhere on a web page and select "Inspect Element" from the popup menu, Firefox will open its Developer Tools and show me the properties for that element and other useful information.

What I'm hoping to find is an Emacs package that offers all of the functionality and information the Firefox Developer Tools offers, but within Emacs.

That information would still be coming from a given tab within a running Firefox instance, but the Firefox Developer Tools window would not even be opened.


texts: How to Configure AucTeX to Preview .pdf File Generated by XeLaTeX?

texts:
How can I achieve this by adding something to ~/.emacs
This is my .emacs
OS: Ubuntu20.04LTS (WSL)
Emacs: 26.3
XeLaTeX: 6.3.2


texts: How to run a macro in a buffer that would take an argument?

texts:
If I want, for example, add all numbers in a  line with a keyboard macro, how can I do it?

It would add:
1 1 34 53
into: 89.

Or, given a word:
asdf
transform it into
fdsa

I know how to define the macro, bind it, and name it.

I have no interest in inputting the numbers in a table. This is meant for easy of use, like typing amount, interest, years, and getting a total amount.


texts: How to get desktop-read to ignore/modify frame size?

texts:
I'm using (desktop-save-mode 1) to save a session which I then reload, but logging in remotely from a different machine with a different resolution display.  Something stored in the desktop winds up setting frame width (but oddly, not height) to the old frame width in pixels, making the frame twice as big as it should be.  I'd like to measure the restored frame in mm or some other unit so that frames will be consistent across displays.  I'm happy to write emacs lisp to get the job done, and it looks like something might be possible using "frameset filters," but I'm lost in the weeds.

How can I get desktop-read to restore my frames to their intended size, even if those frames were saved on a display with different resolution?


texts: how to recover from error in focus-in-hook

texts: I registered a focus-in-hook that generates an error. Now any time I try to execute a command in the minibuffer I get an error and am then unable to execute the load-file that would be required to resolve the error. How can I remove this hook or otherwise recover from this situation?


texts:
The traditional way of opening a file is via C-x C-f (find-file). I don't know since when this has been the case, but in Emacs 27.0.50 (Linux), using the menu bar's File -> Open File invokes the GTK file selection dialog.

Since I prefer this behaviour, I'd like to know:

How can I invoke this GTK file selector via M-x?
What can I write in my Emacs init file so that C-x C-f opens this GTK dialog when I'm running Emacs on X Windows, but reverts to the traditional behaviour when running in the terminal mode?


texts: Emacs installed with the Ubuntu application manager runs but isn't in the $PATH. Where is it?

texts:
Emacs 26.2 is installed with the application manager, not apt-get.

When calling it in the terminal I get :

samusz@samusz-K55:~$ emacs

La commande « emacs » n'a pas été trouvée, mais peut être installée avec :

sudo apt install emacs25
sudo apt install emacs25-nox
sudo apt install e3
sudo apt install emacs25-lucid
sudo apt install jove

(emacs command couldn't be found, but can be installed with...)

samusz@samusz-K55:~$ whereis emacs
emacs: /etc/emacs /usr/share/emacs
samusz@samusz-K55:~$ which emacs
samusz@samusz-K55:~$ ^C
samusz@samusz-K55:~$

there is no binary in /etc/emacs nor /usr/share/emacs, just config files !

So as a get-around I'll uninstall and get fresh binaries but I am interested as to what I do wrong. Or may be Ubuntu is not getting better if they can't configure the path when installing binaries.

I hate it when things get hidden away.

Is this a bug or a feature? (and if does it need reporting where ?)

(I was trying to get pdf-tools working when hit this wall)


texts: helm-projectile-ag : How can I refine the grep results further?

texts:
I have a newb question regarding the use of Helm in the context of Projectile.

I'm using helm-projectile-ag to grep for strings in a large code base. The performance is excellent, but I'm needing to refine search results further.

Typically, I'd get something along these lines, where I'm interested in the Core bits, but want to ignore hits in unrelated files:

Unrelated1/some_file.cpp: void getHash();
Core/include/hash.h: void getHash()
Core/src/bla.cpp: return getHash();
Core/src/again.cpp: a = getHash(b) + getHash(c);
Unrelated2/some_file.cpp: void getHash();

What I would like to do is to refine the results further by file path, so only strings under Core are shown. Is there a way to pass the buffer from helm-projectile-ag to another Helm refining buffer somehow, or to refine the results in the buffer helm-projectile-ag uses?


texts:
Recently I was trapped by void-variable error on eval-after-load.

That is not first time I forget to quote args like:

(eval-after-load 'sql
   '(progn
       ...))

because eval-after-load docs say:

(eval-after-load FILE FORM)

I wrongly expect that FORM is like BODY... for example in when:

(when COND BODY...)

What is the difference between FORM and BODY function call contract?

Why are there FORM when BODY is more convenient?

BODY only for macros and FORM only for functions?

Is (quote (progn ...)) usual way to make multi expression FORM?

UPDATE Seems my guess is right about BODY only for macros and FORM only for functions:

(defmacro with-eval-after-load (file &rest body)
  "Execute BODY after FILE is loaded.
FILE is normally a feature name, but it can also be a file name,
in case that file does not provide any feature."
  (declare (indent 1) (debug t))
  `(eval-after-load ,file (lambda () ,@body)))


texts: Spacemacs not using the theme for tooltips after resizing the window

texts:
I'm using Spacemacs with Solarized dark theme on Arch linux using i3wm, and I'm having some issues with tooltips. If I open Emacs so it only covers part of the screen, the tooltips shows up with the correct font, colors and size. If I fullscreen Emacs (and optionally make it smaller again), the tooltips seems to revert to some standard X11 theme with a black background, white text and very small font (I'm on a HiDPI display). Changing theme and back doesn't revert the correct tooltip theme.

Any idea what is wrong here and how I might fix it? I don't know what information would be useful, and I'm totally new on Emacs.


texts:
Windows 10
Emacs 27.1
From C-x C-f File
Till seeing the file actually open can take almost a minute!
Tried emacs instead of runemacs.
Also Menu-file-visit
All the same
I think there's some Mcafee stuff running
(sorry don't know too much... Office machine!
Just assume standard "corporate setup"??
In any case could'nt get task manager to show some rogue 100% process. But I'm terrible at using windows effectively and am open to being educated )
And maybe this question will find better answers on superuser?? Can move it if that's so...
Is there a more emacs-centric (rather than task-manager — windows centric) way of finding out what emacs is up-to in that long 1 minute?


texts: I'm moving from vim to spacemacs, and the only little frustration I have at the moment is that in vim my workflow tends to involve quitting vim a lot (with :q). I find myself continually exiting spacemacs by mistake - and having to wait for it to restart. Habits die hard. How can I either remap ':q' to quit the buffer (and not spacemacs) or disable ':q' completely to force myself to learn to kill buffers the spacemacs way?


texts:
I found this snippet of code from oremacs

(defmacro csetq (variable value)
  `(funcall (or (get ',variable 'custom-set) 'set-default) ',variable ,value))

I would like to expand this macro so that is can take multiple pairs of arguments similar to setq (e.g. (csetq foo 'bar fod 'baz str "a") etc). I made an initial attempt, but it always returns nil and leaves me with a lot of nested progn forms when expanded.

(defmacro csetq (variable value &rest rest)
  (when variable
      `(progn (funcall (or (get ',variable 'custom-set) 'set-default) ',variable ,value)
              (csetq ,(car rest) ,(cadr rest) ,(cddr rest)))))

Is there a way to fix this macro so that it returns the last value set (similar to setqand does not nest?


texts: Mac OS X problem accessing file via symlink

texts:
GNU Emacs 24 on El Capitan.  When opening a file whose path includes a directory which is a symlink, Emacs emits the following error:

*ERROR*: Wrong type argument: numberp, "Bus error: 10"

If I handle this error, then the file will open but Emacs will hang until it receives a SIGHUP.

The path is a volume mounted as a network share from a Linux VM running on the local machine.  It doesn't seem to occur on a local symlink, but I've only done a limited use case test of this.

I am not using org-mode, and have tried opening the file in Fundamental mode which results in the same problem of Emacs hanging.  I have started emacs without any .emacs file with the same result.

Any suggestions would be great.


texts: whitespace-line-column highlight basing on the column number instead of char count

texts:
config

(require 'whitespace)
(setq whitespace-line-column 80) ;; limit line length
(setq whitespace-style '(face tabs empty trailing lines-tail))

For first line, whitespace-mode correctly highlights characters in line which are over 80 characters

In second line, org symbol (\Rightarrow) is used. whitespace-mode seems to highlight based on the character count instead of column number 80

Need help in making whitespace-mode highlight basing on the column number instead of character count.. or any better alternatives... Thanks

edit:

evaluation (current-column) at the location of first highlighted(pink) l in first line gives 80

evaluating (current-column) at the location of first highlighted(pink) arrow in second line gives 16


texts: How to use arrow keys to select a menu item from an emacs shell buffer

texts:
It is getting more and more common for clis to have little embedded menus (for example the Ionic cli does this, but so do many others) which you navigate with the arrow keys.

Please select the JavaScript framework to use for your new app. To bypass this prompt next time, supply a value for the --type option.

? Framework: (Use arrow keys)
❯ Angular | https://angular.io
  React   | https://reactjs.org

I find that when running these in emacs (in eshell usually but also just regular shell), I cannot select items from the menu as it seems arrow keys are not sent.

What's a reasonable workaround here?


texts: emacs: specify 2 or 4 space indentation for C-j electric-newline-and-maybe-indent

texts:
I'm using emacs 24.  I work on a variety of html files,
sometimes there's blocks of html with two space indentation,
others have four space indentation.

When I press C-j , emacs assumes i want 4 space indentation. How can I quickly tell C-j what kind (2 or 4) indentation I want?

(on my system C-h k gives "electric-newline-and-maybe-indent" for C-j)


texts: How can I access the :file src header argument inside the src block

texts:
I'm wondering how to access the :file header argument passed to a src block, from inside the src block itself?

I'm wondering specifically for python, and in this case ipython with %matplotlib inline as the example below (here I use the ob-ipython library)

#+begin_src ipython :session :file /tmp/py87133eo.png :exports results
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

#+end_src


texts: Automatically closing #ifdef block when editing C code

texts:
When editing LaTeX code, the command latex-close-block inserts an \end{..} that matches the last unclosed \begin{..}. Very handy!

Is there a similar command in c-mode that would close a pending #ifdef? Ideally, I would close

#ifdef __A_COND__

with a nicely commented #endif, like in

#endif /* __A_COND__ */

If such a command does not exist, how would you program it? From scratch or using skeleton.el?


texts: How to automatically press the Tab key to execute minibuffer-complete after executing imenu?

texts:
I first set up this key binding :
(global-set-key (kbd "<f4>") (lambda () (interactive) (other-window -1)))

When I use imenu I always have to perform the following steps:

Step 1: Press M-x
Step 2: type imenu , Press RET
Step 3: Press TAB ;; run minibuffer-complete
Step 4: Press f4 ;; run (other-window -1) for switch to *Completions* buffer
Step 5: Press C-s ;; run isearch-forward

I want to use a function to perform the above 5 steps.

Is this possible?
This is useful when there are a lot of functions.

Similarly, if want to display struct, need to insert between the second and third steps:
Step 3: type Class , Press RET

My current solution is to use xdotool:

show struct list: (global-set-key (kbd "<f8>") (lambda () (interactive) (shell-command "xdotool key alt+x && xdotool type 'imenu' && xdotool key Return && xdotool type 'Class' && xdotool key Return && xdotool key Tab && xdotool key F4 && xdotool key ctrl+s")))

show function list: (global-set-key (kbd "<f9>") (lambda () (interactive) (shell-command "xdotool key alt+x && xdotool type 'imenu' && xdotool key Return && xdotool key Tab && xdotool key F4 && xdotool key ctrl+s")))

I want to quickly locate the item by fuzzy search in *Completions* buffer,  Instead of pressing Tab key complete in the minibuffer


texts: How to capture and link code comments as org agenda items?

texts:
I often see or leave comments in code projects like:

//TODO more efficient hash on keys than BASE64?

Ideally, I would like to be able to highlight a comment as such and org-capture it to an org file like : code.org. The code.org file would contain an org-mode link back to the original file that it was captured in. Then I would be able to treat code.org as an agenda file.


texts: How to stop lsp-mode including headers automatically for C/C++ code?

texts:
Every now and then lsp-mode is adding a header to the C source code I'm working on.

How can this functionality be disabled?


texts: How to disable eldoc for `eval-expression`?

texts:
After a recent update eldoc is turned on by default, even for emacs -Q.
I don't appreciate the noise it generates when I'm using eval-expression.
How do I turn it off?


texts: How can I 'disable' left_C-x and enable only 'right_C'-x

texts:
I'm a emacs user, and my left pinkie start to feel it a bit (overuse of C-x day long) .... so I thought that before crying over some emacs induced RSI, I should unset some bindings so my bad habits would not have any chance at being effective.

I'm wondering: is it possible to enable the C-x binding only with the right ctrl key, and not the left, within emacs ? I could disactivate the key altogether (or even remove it physically from the keyboard while I'm at it) but it seems a bit overkill, and a softer solution would be appreciated.


texts: How to us a shortcut to add semicolon to end of current line?

texts:
Is there a shortcut to add a semicolon to the end of the current line of code?
For instance, M-; inserts a comment at the end of the current line of code.  Is there anything like that for a semicolon?
Currently, I press C-e to move the cursor to the end and type the semicolon ;.
I was wondering if there is a quicker way.


texts: Can I "insert" a backspace character into a buffer?

texts:
I'm trying to tail the output from a command into a buffer, and I just learned that the command occasionally uses long strings of ^H to backspace over previous lines.

Like, the command stdout will first send this line is temporary then send ^H^H^H^H^H^H^H^H^Hpermanent next, so the result in my terminal just looks like this line is permanent.

Is there a simple way to recreate this effect in a buffer?  If at all possible I'd really prefer to avoid iterating over the characters in the output stream and replacing each ^H with a call to delete-char.

I've tried variations on (insert ?^H) but no joy.  ^H appears in the buffer at point, but I want the character before point to be deleted.


texts: Don't insert CLOSED line when node becomes DONE in org-mode

texts:
I want exactly the opposite to this: No "CLOSED" line in org-mode?

Namely, I want emacs to stop inserting those annoying CLOSED lines in DONE nodes. Preferably on a per-file basis.

Is there any way to do this?


texts: Remapped CapsLock (via xcape) Doesn't Work on Spacemacs

texts:
I use an xmodmap script (which in turn uses xcape) which remaps Caps Lock to be a modifier (when it is pressed on conjunction with other keys) and escape (when it is pressed and released on its own).

Before installing spacemacs, this worked fine in emacs (at least in terminal mode). After installing Spacemacs, it doesn't work in terminal mode. That is, pressing CapsLock does nothing (so that I can't, for example, go from insert mode to normal mode).

Here is my actual xmodmap/xcape config:

setxkbmap -layout us
xmodmap -e "keycode 66 = Hyper_L"
xmodmap -e "remove mod4 = Hyper_L"
xmodmap -e "remove lock = Hyper_L"
xmodmap -e "add mod3 = Hyper_L"
xmodmap -e "keycode any = Caps_Lock"
xcape -e "Hyper_L=Escape"

Question: How can I get this intended functionality working with spacemacs?


texts: init.el: Run function only if no other buffers present

texts:
I currently have my *Org Agenda* opening on startup using the following in my init.el:

(setq inhibit-splash-screen t) ;; no welcome screen

(defun agendafocus()
  "Focus on agenda at Startup"
  (org-agenda-list)
  (delete-other-windows))

(add-hook 'after-init-hook #'agendafocus) ;; agenda on startup

However, I would like this to occur only if no file buffers exist, i.e., if buffer-file-name is nil. How would one get this behaviour?

[EDIT]: The solution suggested by Tobias below almost works: When evaluated manually (M-x (agendamode), it works as expected (i.e. it only opens *Org Agenda* if no other file buffer is present), but does not work as a hook, either as an after-init-hook nor as a emacs-startup-hook.


texts: What is the mode for displaying auto-updating values of s-expressions in an emacs-lisp buffer?

texts:
There is a mode for emacs-lisp buffers which allows one to display the value of each  expression line by line, and updates the value of the expressions as soon as these are edited.  It looks something like:

(+ 1 1) -> 2

(* 2 3) -> 6

What is the name of this mode?  I have seen it in action and used it but I have forgotten how it is invoked.


texts: Automatically toggling margin width on resizing

texts:
So I'm using Emacs in Windows (Emacs 24.5.1, Windows 10). I've set a default margin width of 20 on both sides for text-mode, but occasionally I like to resize the window in half (Windows+left or right arrow) so that I can quote something from a browser window or the like.

What would be a good way to have Emacs detect this behavior and adjust the margins appropriately (as it is, there's just a thin slit of text when the window is halved), maybe to 5 or 3 characters on each side?

Alternatively, how could I program a function I could issue that would do this manually? I can't even work out how to do it by issuing setq left-margin-width xx from within a running instance. Heeelp.

Here are the relevant parts of my current .emacs:

(add-hook 'text-mode-hook 'visual-line-mode)

(defun margins ()
(setq left-margin-width 20)
(setq right-margin-width 20))

(add-hook 'text-mode-hook 'margins)


texts: Is it possible to edebug a lambda returned by a function?

texts:
For example,

(defun create-function (number)
  `(lambda () (* ,number ,number)))

(defalias 'square-two (create-function 2) "adds two")

(square-two)


texts: How can I sign in using Google to Emacs StackExchange to post questions

texts:
I am able to browse the Emacs StackExchange site using Emacs with M-x w3m b URL RET

I wanted to try out posting questions and answers to the site using Emacs. The main hurdle I am facing is to sign in using my Google account. In a regular browser the Sign in With Google is a button. In w3m however, I see only Google text on which I can't hit RET.

I can try out posting Q&A only after crossing this hurdle... Any tips?

NOTE: If there are better alternatives that can solve my issue then those are welcome too.


texts: Use global & local org-mode TODO Keywords in a file

texts:
In org-mode, one can define a set of local TODO keywords with the "#+TODO" keyword, or sets can be defined globally with org-todo-keywords. It is also possible to define multiple sets that can be used in parallel.

The problem I'm seeing is that you can apparently define multiple sets globally, or locally.  If you define any set of TODO keywords local to a file, then that file will no longer recognize the global TODO keywords set.

There are cases where I want to use a local keyword for sub-headings in a file, but also use my global keywords (and associated agenda) for the top-level headings.

Is there a way to do this without duplicating the global settings in each file that also defines a set of local keywords?


texts: browse-url: How to search the web for the keyword if the word under cursor (or selected) is not an URL?

texts: The feature is more or less as the same as the navigation bar in most modern browsers: if it is a URL, load it; if not, use the default search engine to search the web for it. How can I achieve that in Emacs, such as modifying the default behavior of browse-url?


texts: Automatically loading a bibliography file depending on buffer filename

texts:
I use org-mode to write a paper, with RefTeX as minor-mode to insert quotations from a BibTeX (.bib) file.

RefTeX needs to be told which .bib file to use. This is done by assigning a value to reftex-default-bibliography.

I would like a .bib file to be automatically assigned, depending on the name of the file I am editing. For example, if I edit a paper called the-life-of-ants.org, RefTeX should automatically load the-life-of-ants.bib, stored in the same folder as the .org file.

If no .bib file with the same name as the .org file is stored in the local directory, my default bibliography file should be loaded instead.

This is in Emacs 25.3.1 on Windows 7.

I've tried a function that is called whenever org-mode is loaded, using a hook in the last line of the code below. (The code also does some unrelated stuff, like changing the default keybinding for inserting citations to make it compatible with org-mode standard bindings.)

(defun org-mode-reftex-setup ()
  (load-library "reftex")
  (and (buffer-file-name)
  (file-exists-p (buffer-file-name))
  (reftex-parse-all))
  (define-key org-mode-map (kbd "C-c (") 'reftex-citation) ; key-binding
  (if (file-exists-p (concat (file-name-sans-extension buffer-file-name) ".bib")) ; either use local .bib file
      (progn
        (setq reftex-default-bibliography
              (convert-standard-filename (concat (file-name-sans-extension buffer-file-name) ".bib")))
        (message "Local bib-file loaded.")) ; or use default .bib file
    (progn
      (setq reftex-default-bibliography
            '"c:\\foo\\bar\\baz\\References.bib")
      (message "No bib-file found. Using default bibliography."))))

(add-hook 'org-mode-hook 'org-mode-reftex-setup)

Upon visiting an Org file, the function is executed as expected, and the correct value (it seems) is assigned to reftex-default-bibliography -- or is it?

M-x eval-expression (message reftex-default-bibliography) tells me:

c:\foo\bar\local-bibliography.bib
"c:\\foo\\bar\\local-bibliography.bib"

I don't understand why two lines are produced, one with quotes and double-backslashes (which are needed, I think, to correctly parse file-paths in MS Windows, and which are produced by convert-standard-filename), and one without.

However, M-x eval-expression reftex-default-bibliography tells me only:

"c:\\foo\\bar\\local-bibliography.bib"

which seems to be correct.

And yet, when I try to insert a reference, I get an error:

reftex-locate-file: Wrong type argument: stringp, 99

What could be the problem here?


texts:
I develop Java programs in Emacs occasionally, and adding a dependency to a dependency-injected class is a common action.

For example, imagine adding the dependency Qux to the following class:

// import statements here

public class Foo {

  private final Bar bar;
  private final Baz baz;

  public Foo(
      Bar bar,
      Baz baz) {
    this.bar = bar;
    this.baz = baz;
  }

  // methods here
}

The following need to happen in order to inject Qux.

Qux must be imported.
The field private final Qux qux must be added to the class.
The parameter Qux qux must be added to the constructor.
The assignment this.qux = qux must be added to the constructor.

After injecting Qux, the class should look like this:

// import statements here

public class Foo {

  private final Bar bar;
  private final Baz baz;
  private final Qux qux;

  public Foo(
      Bar bar,
      Baz baz,
      Qux qux) {
    this.bar = bar;
    this.baz = baz;
    this.qux = qux;
  }

  // methods here
}

I use emacs-eclim, so the first step is already handled via automatic imports. The remainder, however, I have to do by hand, since I do not see any function in eclim that will automatically inject the dependency for me.

How can I use Emacs to quicken this task? The injection is fully defined by the type Qux; everything else is boilerplate, making it a juicy target for automation.


texts:
Is there a simple framework for making previous inputs of completing-read persistent across emacs restarts?
For instance if I start with:
(completing-read "test:" '("a" "b") nil nil) and enter "c" the next time I start emacs and execute I want the collection to be (completing-read "test:" '("a" "b" "c") nil nil) instead. Is there a simple way to achieve this?


texts: How do you perform sql queries in emacs-lisp scripts?

texts:
I am building a database application to index org-mode files (http://kitchingroup.cheme.cmu.edu/blog/2017/01/03/Find-stuff-in-org-mode-anywhere/). The first iteration used emacsql, which worked well for a proof of concept, but it builds a database that isn't easily compatible with other ways to interact with the database because it stores things as lisp-readable values. I would like to try using sql strings in the scripts more directly for CRUD operations on the database so that other scripts, e.g. in Python, or the shell could also interact with the database.

Is there another way to use sql inside of emacs-lisp scripts? In particular a library that would enable syntax like this where ? (or something like it) is a placeholder for values:

(sql-execute "SELECT * FROM stocks WHERE symbol=?" t)

That is apparently a more secure way (https://xkcd.com/327/) to do this than:

(sql-execute (format "SELECT * FROM stocks WHERE symbol=%s" t))

The command would return a list of results? It is not essential that it work on sqlite, eventually I will use a server like postgresql or mysql I think. I have found many sql-modes, repls, etc. but nothing that seems designed for working in scripts.


texts: (To file an emacs bug report) are there services out there that let's me ssh to a clean GNU Linux machine

texts:
I want to file a bug report about emacs.

From what I learnt, bug reports relating to GNU/Linux
are given precedence over more exotic OS's like MacOS.

I can spin up an ubuntu instance in 10 seconds using my (free)
Amazon AWS cloud login. But ubuntu is not "sanctioned"
at https://www.gnu.org/distros/free-distros.html

Is there a quick way to ssh to a "fresh" GNU Linux instance
for the purpose of demo'ing a possible bug.

sidenote1: There used to be a free service called sdf.org, I believe they have
tightened up their signup requirements, and I'm not sure what OS they have

sidenote2: virtualbox slows down my Mac to a crawl, plus my SSD is almost full.


texts: How to auto resize rectangle in artist-mode while writing in it?

texts:
I use the artist-mode more than i can count, and mostly use the rectangle form, especially when writing (my own mindmap/concept map workflow that i come to like) but i always have to fix the part myself when writing inside of it.

Any ways to make the rectangle in artist-mode auto resize or prevent them from breaking when writing inside of it? (as if it was it's own buffer/windows, so text don't go over the limits of the rectangle, without the form breaking)


texts: Hard and soft links (junctions) under Windows

texts:
Let us assume to run the following commands creating links in the Windows prompt (terminal):

> mkdir fooDir
> echo hello> fooDir\foo
> mklink /d fooDirSym fooDir
> mklink /j fooDirJunc fooDir
> mklink /h fooDir\fooHard fooDir\foo
> cd fooDir
> mklink fooSym foo

Moving to Emacs, this works as expected:

(file-truename "path/to/fooDir/fooSym")
    => "path/to/fooDir/foo"
(file-nlinks "path/to/fooDir/foo")
    => 2 (#o2, #x2, ?\C-b)
 ;; The second name should be fooDir/fooHard
(file-truename "c:/p/fooDirSym")
    => "path/to/fooDir"

Now:

(file-truename "path/to/fooDirJunc")
    => "path/to/fooDirJunc"
(file-nlinks "path/to/fooDir/")
    => 1 (#o1, #x1, ?\C-a)

A Windows junction is not counted as a hard link (and in fact it is a soft link) and it is not a symlink.

The questions now are:

How do we identify the pathnames (not only the number) of hard links to foo?
How do we identify the presence and the path of  junctions?


texts: How to change the appearance of list bullets in LaTeX/beamer exports?

texts:
It's very neat that simple org-mode lists get exported to itemize (or enumerate) environments in LaTeX. Yet I would like also to be able to change the face of an \item bullet using square brackets, as with \item[$\Rightarrow$]. I fail to see how this can be easily expressed in org-mode.

-[$\Rightarrow$] is exported to -[$\Rightarrow$] (without \item).
- [$\Rightarrow$] is exported to \item\relax [$\Rightarrow$]

Of course I could use @@beamer:\item[$\Rightarrow$]@@, but this is not really satisfying. Any hint?


texts: Scope minibuffer history to specific Counsel commands

texts: If I run bookmark-jump and use invoke M-p, it cycles through the history of bookmarks specifically. If I run counsel-bookmark-jump, M-p cycles through the generic minibuffer history, which is more or less useless. How can I ensure that minibuffer history is scoped to specific counsel commands?


texts: Using a different font for each major mode

texts:
Is it possible to set different fonts following the major mode? Say Inconsolata-12 in org-mode buffers and Symbola-12 in all remaining modes.
Or at least, is it possible to do a

(set-frame-font "Inconsolata" t)

after switching to org-mode buffers?


texts: py-indent-or-complete leaves the *Python Completion* buffer open

texts:
I experience when using TAB bound to py-indent-or-complete that it gives me completion suggestions. however when leaving, or deciding the completion, the *Python Completion* buffer is left open instead of getting buried. I also experience that after tab completing the word at point a newline is needlessly inserted moving me one line down.

What are the underlying settings to configure these two things when using py-indent-or-complete?


texts:
I am trying to debug a problem with the alert.el package using edebug.  However, I am unable to step through the alert function.

I expect the debugger to enter the function and allow me to step through.  Instead, it terminates.

Here is what I'm doing:

Open an Emacs instance opened with emacs -Q
Evaluate (package-initialize)
Call C-u C-M-x on (alert "Hello, world!")

At this point, I see an indicator in my fringe.

Press i to step into the function call

On pressing i, I quickly see "Go..." printed to the minibuffer and the fringe indicator disappears.

I am no longer debugging.

Checking C-h f alert shows me that it is an autoloaded function.  Might this be affecting my ability to step into it?

I have tried toggling (debug-on-error) and stepping through with d.  However, I can't see the source code while stepping.  Whenever I try to open another buffer with the source code in it, pressing d in the *Backtrace* closes the source code buffer.  Is there a way to use (debug-on-error) and see the source code while stepping through execution?

Any advice you have for debugging is welcome.


texts: org-mode saving buffer has long delay, how to tune it?

texts:
I'm using emacs "25.0.92.1", with Prelude customization on Windows 7. I mainly use org-mode.
I found that org-mode takes long delay to save buffer (save-buffer), as long as the edit is more than
several dozen characters. It may take as long as 10 seconds, not able to continue editing.

I tried even with emacs -Q, it will still takes about 5 seconds.

(I also noticed that it takes long time to open and load org file.)

The file in question has about 500 lines, some of the lines may be long of about 200 hundred characters.

I also tried to increase gc-cons-threshold, but seems not effect.

I only have last option to go back to version 24.x to try my luck.

Could you please your insights or experience.

Thanks,


texts: Dired: manual files sorting for specific directories

texts:
I have a directory with many folder. When I open it in dired I see this:

bundles
ckeditor
companies
contries
failitators
induction
jquery_update
lwt_shared
members
messages
offices
...

I often work upon files from specific directory and my idea was to create a file with sorting order. And make the folder I need now to float to the top. All the other dirs should be sorted by name.

For example, I am working upon members and offices dirs:

members
offices
bundles
ckeditor
companies
...

And our sorting file located in parent dir should be something like this:

members
offices

Then Emacs will know, that members and offices must be put at the top. Is it possible to implement it? I read http://www.emacswiki.org/emacs/DiredSorting, and it says, that sorting can be changed by customizing per-directory local variables.

But how should I write this file?


texts:
Does anybody know how to clearly indicate in the mode-line that I'm working on a remote file (e.g. with the color of the buffer name, model-line background or some small tag).

I use tramp to work remotely and my mode line is customized with powerline.

Thank you!


texts: Changing the default description for org-mode file links

texts:
The following is a very common workflow for me

Open a dired buffer, and place cursor on a file.
Invoke M-x org-store-link.
Visit an org file (that's usually in the same directory), and type C-c C-l RET to insert the link.

This way, org-mode inserts a link like the following:

[[file:some-file.org][file:~/Dropbox/Work/some-file.org]]

which displays on the buffer like this:

file:~/Dropbox/Work/some-file.org

It seems silly that org would use a relative file name for the link's
address, but use a long absolute file name for the human-readable description.

I would like to change this automatically created description, so that
it always shows just the file name (no directories). In the
example above it would look like some-file.org or perhaps
file:some-file.org.

How can I customize the automatic description of links inserted with C-c C-l RET?


texts: Emacs font-highlighting does not work on my own files?

texts:
I have an issue that probably has been asked and answered before but I am unable to find it because I seem to be using the wrong search terms for it.
However, the issue I have is that if I make my own file, which I have my bash-aliases in e.i ~/.bash_aliases I get no syntax highlighting as I am getting in my .bashrc? When I am making a new systemd service I however get syntax/font highlighting?


texts:
When I type M-s-h emacs reports: M-s-˙ is undefined

That tiny dot is the 'DOT ABOVE' (U+02D9) character.

I'm on OS X. This is happening when I use the emacs-plus build. With emacs-mac port I don't see this behavior.

Is there any way for me to debug this?


texts: What's the recommended way for clocking and archiving with org-mode

texts:
I recently started clocking my tasks with org-mode and it's great. I now know how much time I spend on each project I am working on. Each project has multiple subtasks, but by setting "maxlevel:1" I can have a project level report.

I like to clean up my org file regularly by archiving the done tasks. However, it seems clock reports in org-mode consider archived tasks to be from separate projects. Even if I have two archived tasks from the same project they appear in the clock table as two projects (because the structure is duplicated in the archive every time I archive a task).

What is the recommended way to handle this? Ideally I would like to still archive tasks but create a clock report that combines the info from the my files with the archive.


texts: Dynamic TOC with an org subtree /element on a new window

texts:
How can I set up a dynamic TOC with an org subtree on a new window? (TOC on the left, org heading and contents on the right.) The following functions by @blujay from

How can I get an org-mode outline in a 2nd buffer as a dynamic table of contents?

gets me most of the way there. Adding (org-narrow-to-element) or (org-narrow-to-subtree) to the second function (my/jump-to-point-and-show) opens the narrowed heading, but as I click through the headings in the TOC, subsequent headings don't open as expected. Also only the heading shows, but the contents stay collapsed unless I press TAB.

Here's the function from the StackExchange page linked above:

 (defun my/open-tree-view ()
  "Open a clone of the current buffer to the left, resize it to 30 columns, and bind <mouse-1> to jump to the same position in the base buffer."
  (interactive)
  (let ((new-buffer-name (concat "<tree>" (buffer-name))))
    ;; Create tree buffer
    (split-window-right 30)
    (if (get-buffer new-buffer-name)
        (switch-to-buffer new-buffer-name)  ; Use existing tree buffer
      ;; Make new tree buffer
      (progn  (clone-indirect-buffer new-buffer-name nil t)
              (switch-to-buffer new-buffer-name)
              (read-only-mode)
              (hide-body)
              (toggle-truncate-lines)

              ;; Do this twice in case the point is in a hidden line
              (dotimes (_ 2 (forward-line 0)))

              ;; Map keys
              (use-local-map (copy-keymap outline-mode-map))
              (local-set-key (kbd "q") 'delete-window)
              (mapc (lambda (key) (local-set-key (kbd key) 'my/jump-to-point-and-show))
                    '("<mouse-1>" "RET"))))))

(defun my/jump-to-point-and-show ()
  "Switch to a cloned buffer's base buffer and move point to the cursor position in the clone."
  (interactive)
  (let ((buf (buffer-base-buffer)))
    (unless buf
      (error "You need to be in a cloned buffer!"))
    (let ((pos (point))
          (win (car (get-buffer-window-list buf))))
      (if win
          (select-window win)
        (other-window 1)
        (switch-to-buffer buf))
      (goto-char pos)
      (when (invisible-p (point))
        (show-branches)))))

(I would also like to thank @blujay for the code snippets.)


texts: How to create a defcustom variable that accepts only a vector of strings?

texts:
I am using repeat for now. But I don't know how to have the same for vector.

EDIT: I want INS and DEL options like in repeat.


texts: How to run a command via elisp, completely ignoring its output and status? (fire and forget)

texts:
Currently I'm using shell command - which makes a buffer, showing the output, sometimes locking emacs.

What is a good way to run a process that:

Doesn't make a buffer.
Doesn't lock emacs.
Ignores the stdout/stderr.


texts: How can I set the global value of a symbol created from a string?

texts:
I'm trying to make this little convenience function work:

(defun my-make-hook (when procedure)
     (let ((hook-symbol (intern (concat
                                 (substring (symbol-name when) 1)
                                 "-"
                                 (symbol-name procedure)
                                 "-hook"))))
       (unless (boundp hook-symbol)
         (set hook-symbol nil)
         (advice-add procedure when (lambda (&rest _) (run-hooks hook-symbol)))
         hook-symbol)))

But I'm getting an error that the interned symbol is void, and I believe I may actually be somehow setting the value of the symbol hook-symbol itself, rather than the symbol that hook-symbol evaluates to.

EDIT: I'm calling it with, e.g., (my-make-hook :after 'load-theme).


texts: How to suppress certain parts of gud-gdb -i=mi output in gud buffer?

texts:
I start gdb in emacs with 'gdb' command. Is there a way to hide certain lines from being shown in gud buffer?
For example, when I do C-c C-c on a running program, I see the following in the buffer:
Program received signal SIGINT, Interrupt.
0x0000555555555182 in main (argc=1, argv=0x7fffffffdf58) at test.cpp:6
6     for ( i=0;i<2000000000;++i){

Is there any way I can configure emacs to show a shorter string instead, for example
"Interrupt test.cpp:6"?


texts: How do use Emacs to look up a function in Python?

texts:
What is the easiest way to configure Emacs to be able to look up where a function is defined? I want to highlight it in Emacs and press a key combo to look up where the source of the function is.

Can you also find out where a specific function is being used?

This is easily done in PyCharm, but can it also be easily done in Emacs?


texts: How could i read all my unread / new mail from different accounts in one group or topic?

texts:
i want to read all my unread /new messages from different IMAP accounts in one Gnus group. As far as i read in the manual, it could be possible with topics or virtual groups.

But i do not understand how i could configure it.

Any clues?

I'm on Linux Mint 19.1 with Emacs 26.1.


texts: How to cycle between two windows when I have more than two open?

texts:
Scenario: I have several (more than 2) windows open. I actively work with two of them. How do I best jump from one window to another, and back, with one command?

I use ace-window; it's great but I don't want to press window number every time.
I know about next-window / prev-window, but these are two different commands.

What I'm looking for is something that remembers what the previous windows was when I select another window, and gets back to it. Invoked repeatedly, it would switch between the last two windows, Alt-Tab-style.

Where do I look?


texts:
I am using spacemacs to work on a few different projects and these projects have vastly different coding standards.  Tabs vs spaces, 80 columns vs 100 columns, etc, etc.  I'm trying to define a way to apply a handful of different styles based on directory.  I don't want to hard code project paths into my .spacemacs nor do I want to litter my project directory with editor config data.  For this reason, I'm trying to define a class of settings and then apply them to a directory.

I have this chunk in my .spacemacs in dotspacemacs/user-config:

  (dir-locals-set-class-variables 'linux-kernel
                                  '(c-mode . ((indent-tabs-mode . 't)
                                              (c-default-style  . "linux")
                                              (c-basic-offset   . 8)
                                              (tab-width        . 8)
                                              (fill-column      . 80)
                                              (evil-shift-width . 8))))

Then I open up a file in a kernel tree and none of these settings are applied.  Of course this is expected because I have defined a dir locals class and not applied it.  So then I do :(dir-locals-set-directory-class "/path/to/some/kernel/dir" 'linux-kernel), but the kernel code that I was editing (under the folder mentioned in the previous command) doesn't have any of the new settings applied.  Any additional files opened in that directory also don't have the settings applied.

I'm pretty new to emacs, so I could be making a really basic mistake.  Did I apply the class correctly?


texts: I have an org file with a few clock tables up front. I would like to see them folded when opening the file. Is this possible?


texts: UnicodeDecodeError in my Inferior Python buffer

texts:
While trying to run a python script in an Inferior Python buffer for Python 3.3.5 in my Emacs 24.3.1 GTK+ window, I get a

>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1332:
 ordinal not in range(128)

This even happens when all my buffer contains is the minimum to make it a python script containing a unicode character.

#!/usr/bin/env python3
"ε"

There appears to also be some magic that replaces all non-ascii characters from the first line (?) of input with whitespace, because just

"ε"

gives me the string " ", trying to do ε=4 results in an IndentationError, and ord("ε") on the first line of a file returns 32. This may be related; however, if the non-ascii symbols appear after the first line, all these constructions result in a UnicodeDecodeError instead.

As you can see, I haven't even started outputting any unicode symbols, and the Inferior Python buffer accepts input of unicode characters. Running the same python script in a terminal (urxvt or a random tty) works without problems as well.

What do I need to change to make it work?


texts:
I have pdftools install and wish to use it with auctex. However, I cannot view the pdf as I get the error:

PNG image supported not compiled into Emacs

Output is simply the raw pdf.

I am using emacs 25.3 and running emacs Windows 10.
Any help appreciated.


texts: Setting `ido-ignore-buffers' doesn't cause buffers to be ignored, where's the error?

texts:
I set value of `ido-ignore-buffers' this way:

(defvar uki-ido-ignored-buffer-names '("*grep*" "*Messages*"))

(defun uki-ido-ignore-most-star-buffers (buffer)
    (member (buffer-name) uki-ido-ignored-buffer-names))

(eval-after-load 'ido
  '(setq ido-ignore-buffers
         (list "\\` " "^[ *\t]" "^\\*Org Src" "^\\*info" "^\\*magit:"
               #'uki-ido-ignore-most-star-buffers)))

But when I run  (ido-switch-buffer), I see buffers beginning with "*Org Src" (visible in the following screenshot).

Why does my regexp fail to "catch" it?


texts: autofill a cpp file based on the .h file

texts:
suppose I have x.h

class X {
void f();
void g();
}

in x.cpp

#include "x.h"

can I just entry a command with "X" as a parameter, then I can get

void X::f() {}
void X::g() {}


texts: How do I test if my Emacs is in minGW environment?

texts:
I have a elisp script that needs to work across different OS platform. So I need to use the convert-standard-filename to make sure the filename confirms to OS standard.

But I found Emacs for Windows can handle Windows filename correctly, and it somehow cannot handle the filename returned by the convert-standard-filename.

So I need a way to test if the script is executing in s minGW environment, and return the raw filename.


texts: How can I add default shell commands for various file types?

texts:
When I use ! on a *.tar.bz2 file in Dired, I'm presented with the following prompt:

! on WANem_3.0_Beta2.tar.bz2: {3 guesses} [bunzip2 -c * | tar xvf -] -!-

How can I add similar functionality for other file types?


texts: Reuse other command's "interactive" form

texts:
Example, I want to define a package-open-homepage command, which reuses C-h P (describe-package)'s "interactive" form. I don't want to copy-and-paste because it is too long. The following

(eval
 `(defun package-open-homepage (pkg)
    "Open homepage of pkg, or do nothing if none."
    ,(interactive-form 'describe-package)
    (when-let ((desc (cadr (assq pkg package-alist)))
               (extras (package-desc-extras desc))
               (homepage (cdr (assoc :url extras))))
      (browse-url homepage))))

works, but I never use eval before, is this use case the reason that why eval is needed? and is there any other way without using eval?

By the way, I already know (put 'package-open-homepage 'interactive-form (interactive-form 'describe-package)) works.


texts: A custom layer, org-roam, only works on the 3rd restart of spacemacs

texts:
I'm using Spacemacs v.0.200.13, and GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-09-16.

I'd like to install and use the org-roam package.

The instructions indicate that Spacemacs users should create a custom layer, use use-package to fetch the package using recipe :fetcher github :repo (url).

I have done so.

/home/me/.emacs.d/private/org-roam/packages.el

(defconst org-roam-packages
  '((org-roam :location
              (recipe :fetcher github :repo "jethrokuan/org-roam" :branch "develop"))))

(defun org-roam/init-org-roam ()
  (use-package org-roam
    :after org
    :hook
    (after-init . org-roam-mode)
    :custom
    (org-roam-directory "~/Dropbox/org/notes")
    :init
    (progn
      (spacemacs/declare-prefix "ar" "org-roam")
      (spacemacs/set-leader-keys
        "arl" 'org-roam
        "art" 'org-roam-today
        "arf" 'org-roam-find-file
        "arg" 'org-roam-show-graph)

      (spacemacs/declare-prefix-for-mode 'org-mode "mr" "org-roam")
      (spacemacs/set-leader-keys-for-major-mode 'org-mode
        "rl" 'org-roam
        "rt" 'org-roam-today
        "rb" 'org-roam-switch-to-buffer
        "rf" 'org-roam-find-file
        "ri" 'org-roam-insert
        "rg" 'org-roam-show-graph))))

Then, in my .spacemacs, I add the package to my dotspacemacs-configuration-layers.

.spacemacs

   dotspacemacs-configuration-layers
   '(
     org-roam
     )

Now, if I restart emacs using restart-emacs-resume-layouts, and attempt to run any of the org-roam functions, I get the following error:

command-execute: Wrong type argument: commandp, org-roam-find-file

Looking through my messages, I see no obvious warnings or errors.

Then, I delete org-roam from my dotspacemacs-configuration-layers. I restart-emacs-resume-layouts. I re-add org-roam to my ``dotspacemacs-configuration-layers. Now, if I run any of theorg-roamfunctions, they work. However, I get the infamousSPC SPC is undefinederror, which I usually take to mean there's some kind of error in my.spacemacs. Again, though, nothing inmessages.` And, if I restart again, the functions again error.

Here is my .spacemacs in its entirety.

If I do describe-package when spacemacs is in a state where any of the org-roam functions give the commandp error, I see:

org-roam is an installed package.

     Status: Installed in ‘org-roam-20200224.258/’ (unsigned). Delete
    Version: 20200224.258
    Summary: Roam Research replica with Org-mode
   Requires: emacs-26.1, dash-2.13, f-0.17.2, s-1.12.0, async-1.9.4, org-9.0
   Homepage: https://github.com/jethrokuan/org-roam
   Keywords: org-mode roam convenience

How can I successfully use org-roam while still maintaining my SPC SPC keybindings, and in a way where it persists across emacs restarts?

EDIT: If I delete the org-roam folder in .emacs.d/elpa, then restart emacs, I get into the state wherein org-roam functions work, but I get SPC SPC is undefined errors.

Here is my entire messages buffer after a restart into the state where org-roam functions work, but SPC SPC doesn't.


texts: I am new to Emacs and I am trying to install pdf-tools on Windows. I am following this, but I just couldn't understand what to do from the step 3. Could someone explain to me in very simple language what to do? I have very little experience and don't really understand this language.